Skip to content

Commit 24e8f05

Browse files
Fix bug: The debug session never stops even after the remote application has detached the debug connection (#274)
Signed-off-by: Jinbo Wang <[email protected]>
1 parent 7ef552e commit 24e8f05

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
7979
context.setVmTerminated();
8080
context.getProtocolServer().sendEvent(new Events.ExitedEvent(0));
8181
} else if (event instanceof VMDisconnectEvent) {
82-
// ignore since LaunchRequestHandler has already handled.
82+
if (context.isAttached()) {
83+
context.setVmTerminated();
84+
context.getProtocolServer().sendEvent(new Events.TerminatedEvent());
85+
// Terminate eventHub thread.
86+
try {
87+
debugSession.getEventHub().close();
88+
} catch (Exception e) {
89+
// do nothing.
90+
}
91+
} else {
92+
// Skip it when the debugger is in launch mode, because LaunchRequestHandler will handle the event there.
93+
}
8394
} else if (event instanceof ThreadStartEvent) {
8495
ThreadReference startThread = ((ThreadStartEvent) event).thread();
8596
Events.ThreadEvent threadEvent = new Events.ThreadEvent("started", startThread.uniqueID());

0 commit comments

Comments
 (0)