Bug 533107 - JDIThread$StepHandler.handleEvent() throws
ClassCastException when stepResultMethod is null for MethodExitEvent

Change-Id: I8ee47f1d8653dda27491b184332c2e1edb1d2493
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
index 13cfead..45ee0ad 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
@@ -2834,14 +2834,17 @@
 					if (stepResultMethod != null) {
 						MethodExitEvent methodExitEvent = (MethodExitEvent) event;
 						if (methodExitEvent.location().method().equals(stepResultMethod)) {
-							fStepResultCandidate = new MethodResult(fStepResultMethod, fStepReturnTargetFrameCount, methodExitEvent.returnValue(), ResultType.returned);
+							fStepResultCandidate = new MethodResult(stepResultMethod, fStepReturnTargetFrameCount, methodExitEvent.returnValue(), ResultType.returned);
 						}
-						return true;
 					}
+					return true;
 				}
 				if (event instanceof ExceptionEvent) {
 					ExceptionEvent exceptionEvent = (ExceptionEvent) event;
-					fStepResultCandidate = new MethodResult(fStepResultMethod, fStepReturnTargetFrameCount, exceptionEvent.exception(), ResultType.threw);
+					Method stepResultMethod = fStepResultMethod;
+					if (stepResultMethod != null) { // should always be true unless some third-party plugins manipulate internal state
+						fStepResultCandidate = new MethodResult(stepResultMethod, fStepReturnTargetFrameCount, exceptionEvent.exception(), ResultType.threw);
+					}
 					return true;
 				}
 				if (event instanceof MethodEntryEvent) {