Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #763 from eharris369/CW3119-detectTimeoutFromPortF…
Browse files Browse the repository at this point in the history
…orward-0.13.0

CW Issue #3119: Better detection and message for debug attach timeout 0.13.0
  • Loading branch information
eharris369 authored Jun 10, 2020
2 parents f649937 + 9273b20 commit 03595a3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class CodewindEclipseApplication extends CodewindApplication {
public static final String QUICK_FIX_DESCRIPTION = "quickFixDescription";

// in seconds
public static final int DEFAULT_DEBUG_CONNECT_TIMEOUT = 10;
public static final int DEFAULT_DEBUG_CONNECT_TIMEOUT = 180;

// New consoles
private Set<SocketConsole> activeConsoles = new HashSet<SocketConsole>();
Expand Down Expand Up @@ -154,6 +154,8 @@ protected IStatus run(IProgressMonitor monitor) {
return launcher.launchDebugger(app, monitor);
}
}
} catch (CoreException e) {
return e.getStatus();
} catch (Exception e) {
Logger.logError("An error occurred while trying to launch the debugger for project: " + app.name, e); //$NON-NLS-1$
return new Status(IStatus.ERROR, CodewindCorePlugin.PLUGIN_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.sun.jdi.connect.AttachingConnector;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.spi.ClosedConnectionException;

@SuppressWarnings("restriction")
public class CodewindDebugConnector {
Expand Down Expand Up @@ -95,6 +96,15 @@ public static IDebugTarget connectDebugger(ILaunch launch, CodewindApplication a
// do nothing
}
}

// Check for timeout
if (itr <= 0 && vm == null && (ex == null || ex instanceof ClosedConnectionException)) {
// Log any exception
if (ex != null) {
Logger.logError("Debug connect timed out. Last exception was: " + ex.toString(), ex);
}
throw new CoreException(new Status(IStatus.ERROR, CodewindCorePlugin.PLUGIN_ID, Messages.DebuggerConnectFailureTimeoutMsg, ex));
}

if (ex instanceof IllegalConnectorArgumentsException) {
throw (IllegalConnectorArgumentsException) ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void launchInner(ILaunchConfiguration config, String launchMode, ILaunch
launch.addDebugTarget(debugTarget);
} else if (!monitor.isCanceled()) {
Logger.logError("Debugger connect timeout for project: " + app.name); //$NON-NLS-1$
CoreUtil.openDialog(true, Messages.DebuggerConnectFailureDialogTitle, Messages.DebuggerConnectFailureDialogMsg);
CoreUtil.openDialog(true, Messages.DebuggerConnectFailureDialogTitle, Messages.DebuggerConnectFailureTimeoutMsg);
getLaunchManager().removeLaunch(launch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Messages extends NLS {

public static String DebugLaunchConfigName;
public static String DebuggerConnectFailureDialogTitle;
public static String DebuggerConnectFailureDialogMsg;
public static String DebuggerConnectFailureTimeoutMsg;

public static String RemoteDebugErrorTitle;
public static String RemoteDebugPortForwardErrorWithMsg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ReconnectJob_ReconnectErrorDialogMsg=Eclipse could not reconnect to {0}.\nRecrea

DebugLaunchConfigName=Debugging {0} at {1}:{2}
DebuggerConnectFailureDialogTitle=The debugger failed to connect
DebuggerConnectFailureDialogMsg=The debugger failed to connect in time. Increase the debug timeout in the Codewind preferences.
DebuggerConnectFailureTimeoutMsg=The debugger failed to connect in time. Increase the debug timeout in the Codewind preferences then right-click on the project and select Attach Debugger.

RemoteDebugErrorTitle=Debug Setup Error
RemoteDebugPortForwardErrorWithMsg=An error occurred trying to port forward the debug port for the {0} project: {1}
Expand Down

0 comments on commit 03595a3

Please sign in to comment.