|
19 | 19 | import java.io.File; |
20 | 20 | import java.io.PrintWriter; |
21 | 21 | import java.io.StringWriter; |
| 22 | +import java.net.BindException; |
22 | 23 | import java.util.ArrayList; |
23 | 24 | import java.util.Arrays; |
24 | 25 | import java.util.Collection; |
|
177 | 178 | @SuppressWarnings("deprecation") |
178 | 179 | public abstract class AbstractDebugTest extends TestCase implements IEvaluationListener { |
179 | 180 |
|
| 181 | + private static final int SOCKET_BIND_ERROR_MAX_RETRIES = 3; |
180 | 182 | private static boolean setupFirstTest = false; |
181 | 183 |
|
182 | 184 | public static final String MULTI_OUTPUT_PROJECT_NAME = "MultiOutput"; |
@@ -219,7 +221,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation |
219 | 221 | "OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982", |
220 | 222 | "SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2", "compare.CompareObjectsStringTest", "compare.CompareListObjects", |
221 | 223 | "compare.CompareMapObjects", "compare.CompareSetObjects", "compare.CompareNormalObjects", "compare.CompareArrayObjects", |
222 | | - "StatementStep", "StatementStepArgument", "StatementStepNested", "StatementStepWithOperations" }; |
| 224 | + "StatementStep", "StatementStepArgument", "StatementStepNested", "StatementStepWithOperations", "WatchItemContext" }; |
223 | 225 |
|
224 | 226 | /** |
225 | 227 | * the default timeout |
@@ -551,6 +553,9 @@ synchronized void assert18Project() { |
551 | 553 | cfgs.add(createLaunchConfiguration(jp, "LambdaBreakpoints1")); |
552 | 554 | cfgs.add(createLaunchConfiguration(jp, "GH275")); |
553 | 555 | cfgs.add(createLaunchConfiguration(jp, "LambdaTest")); |
| 556 | + cfgs.add(createLaunchConfiguration(jp, "InnerClassBug")); |
| 557 | + cfgs.add(createLaunchConfiguration(jp, "SuperClass")); |
| 558 | + cfgs.add(createLaunchConfiguration(jp, "SubClass")); |
554 | 559 | loaded18 = true; |
555 | 560 | waitForBuild(); |
556 | 561 | } |
@@ -1487,13 +1492,7 @@ protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWai |
1487 | 1492 | * if the event is never received. |
1488 | 1493 | */ |
1489 | 1494 | protected Object launchAndWait(ILaunchConfiguration configuration, String mode, DebugEventWaiter waiter, boolean register) throws CoreException { |
1490 | | - ILaunch launch; |
1491 | | - try { |
1492 | | - launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register); |
1493 | | - } catch (Throwable t) { |
1494 | | - logProcessConsoleContents(); |
1495 | | - throw t; |
1496 | | - } |
| 1495 | + ILaunch launch = launchConfig(configuration, mode, register); |
1497 | 1496 | Object suspendee= waiter.waitForEvent(); |
1498 | 1497 | if (suspendee == null) { |
1499 | 1498 | StringBuilder buf = new StringBuilder(); |
@@ -1536,8 +1535,6 @@ protected Object launchAndWait(ILaunchConfiguration configuration, String mode, |
1536 | 1535 | return suspendee; |
1537 | 1536 | } |
1538 | 1537 |
|
1539 | | - |
1540 | | - |
1541 | 1538 | /** |
1542 | 1539 | * Launches the type with the given name, and waits for a |
1543 | 1540 | * suspend event in that program. Returns the thread in which the suspend |
@@ -2225,6 +2222,20 @@ protected IJavaMethodBreakpoint createMethodBreakpoint(IJavaProject project, Str |
2225 | 2222 | protected IJavaMethodBreakpoint createMethodBreakpoint(String packageName, String cuName, String typeName, String methodName, String methodSignature, boolean entry, boolean exit) throws Exception { |
2226 | 2223 | IType type = getType(packageName, cuName, typeName); |
2227 | 2224 | assertNotNull("did not find type to install breakpoint in", type); //$NON-NLS-1$ |
| 2225 | + return createMethodBreakpoint(type, methodName, methodSignature, entry, exit); |
| 2226 | + } |
| 2227 | + |
| 2228 | + /** |
| 2229 | + * Creates a method breakpoint in a specified type. |
| 2230 | + * |
| 2231 | + * @param type the type in which the method breakpoint is set |
| 2232 | + * @param methodName method or <code>null</code> for all methods |
| 2233 | + * @param methodSignature JLS method signature or <code>null</code> for all methods with the given name |
| 2234 | + * @param entry whether to break on entry |
| 2235 | + * @param exit whether to break on exit |
| 2236 | + * @return method breakpoint |
| 2237 | + */ |
| 2238 | + protected IJavaMethodBreakpoint createMethodBreakpoint(IType type, String methodName, String methodSignature, boolean entry, boolean exit) throws Exception { |
2228 | 2239 | IMethod method= null; |
2229 | 2240 | if (methodSignature != null && methodName != null) { |
2230 | 2241 | if (type != null ) { |
@@ -3207,6 +3218,28 @@ private static void logVMChange(String message, IVMInstall vm) { |
3207 | 3218 | JDIDebugPlugin.log(status); |
3208 | 3219 | } |
3209 | 3220 |
|
| 3221 | + private static ILaunch launchConfig(ILaunchConfiguration configuration, String mode, boolean register) throws CoreException { |
| 3222 | + ILaunch launch = null; |
| 3223 | + for (int retry = 1; retry <= SOCKET_BIND_ERROR_MAX_RETRIES; ++retry) { |
| 3224 | + try { |
| 3225 | + launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register); |
| 3226 | + break; |
| 3227 | + } catch (CoreException e) { |
| 3228 | + Throwable cause = e.getStatus().getException(); |
| 3229 | + if (retry < SOCKET_BIND_ERROR_MAX_RETRIES && cause instanceof BindException) { |
| 3230 | + // port might be in use between checking for a free port and launching, try a few times |
| 3231 | + DebugPlugin.log(Status.error("Could not bind socket for debugging, retry: " + retry, e)); |
| 3232 | + } else { |
| 3233 | + throw e; |
| 3234 | + } |
| 3235 | + } catch (Throwable t) { |
| 3236 | + logProcessConsoleContents(); |
| 3237 | + throw t; |
| 3238 | + } |
| 3239 | + } |
| 3240 | + return launch; |
| 3241 | + } |
| 3242 | + |
3210 | 3243 | private static void logProcessConsoleContents() { |
3211 | 3244 | try { |
3212 | 3245 | StringBuilder buf = new StringBuilder(); |
|
0 commit comments