Skip to content

Commit b1e05e3

Browse files
committed
Ignore VMDisconnected on detach; reorder terminate
Wrap vm.dispose() in a try/catch to ignore VMDisconnectedException when the VM has already disconnected (e.g. process terminated) to avoid spurious errors during detach. Reorder calls in DisconnectRequestHandler to invoke terminate() before detach() when terminateDebuggee is true and the session is not attached, ensuring the debuggee is terminated prior to detaching.
1 parent ae2847e commit b1e05e3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ public void resume() {
117117

118118
@Override
119119
public void detach() {
120-
vm.dispose();
120+
try {
121+
vm.dispose();
122+
} catch (VMDisconnectedException ex) {
123+
// ignore — VM already disconnected (e.g. process was terminated first)
124+
}
121125
}
122126

123127
@Override

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/DisconnectRequestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public void destroyDebugSession(Command command, Arguments arguments, Response r
2626
IDebugSession debugSession = context.getDebugSession();
2727
if (debugSession != null) {
2828
if (disconnectArguments.terminateDebuggee && !context.isAttached()) {
29-
debugSession.detach();
3029
debugSession.terminate();
30+
debugSession.detach();
3131
} else {
3232
debugSession.detach();
3333
}

0 commit comments

Comments
 (0)