Skip to content

Commit fdd4831

Browse files
committed
Always detach debug session on terminate
Wrap debugSession.terminate() in a try/finally so debugSession.detach() is always invoked when terminateDebuggee is true and the session is not attached. This ensures the session is detached even if terminate() throws, avoiding potential dangling sessions. Other detach logic is unchanged.
1 parent b1e05e3 commit fdd4831

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ 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.terminate();
30-
debugSession.detach();
29+
try {
30+
debugSession.terminate();
31+
} finally {
32+
debugSession.detach();
33+
}
3134
} else {
3235
debugSession.detach();
3336
}

0 commit comments

Comments
 (0)