Skip to content

Commit 55e29be

Browse files
authored
remove com.sun.jdi.VMDisconnectedException from reasonable places. (microsoft#104)
* add logs for attaching errors. * fix the user error log entry: org.eclipse.jdi.internal.connect.PacketSendManagersendPacket at PacketSendManager.java Line 90 org.eclipse.jdi.internal.MirrorImplrequestVM at MirrorImpl.java Line 187 org.eclipse.jdi.internal.MirrorImplrequestVM at MirrorImpl.java Line 268 org.eclipse.jdi.internal.VirtualMachineImplgetIDSizes at VirtualMachineImpl.java Line 984 org.eclipse.jdi.internal.VirtualMachineImplpacketSendManager at VirtualMachineImpl.java Line 343 org.eclipse.jdi.internal.MirrorImplrequestVM at MirrorImpl.java Line 187 org.eclipse.jdi.internal.MirrorImplrequestVM at MirrorImpl.java Line 268 org.eclipse.jdi.internal.VirtualMachineImplgetVersionInfo at VirtualMachineImpl.java Line 1010 org.eclipse.jdi.internal.VirtualMachineImplversion at VirtualMachineImpl.java Line 939 com.microsoft.java.debug.core.adapter.handler.AttachRequestHandlerhandle at AttachRequestHandler.java Line 65 com.microsoft.java.debug.core.adapter.DebugAdapterdispatchRequest at DebugAdapter.java Line 80 com.microsoft.java.debug.core.adapter.ProtocolServerdispatchRequest at ProtocolServer.java Line 66 com.microsoft.java.debug.core.protocol.AbstractProtocolServerprocessData at AbstractProtocolServer.java Line 166 com.microsoft.java.debug.core.protocol.AbstractProtocolServerstart at AbstractProtocolServer.java Line 80 com.microsoft.java.debug.core.adapter.ProtocolServerstart at ProtocolServer.java Line 53 com.microsoft.java.debug.plugin.internal.JavaDebugServer$2run at JavaDebugServer.java Line 136 java.util.concurrent.Executors$RunnableAdaptercall at Executors.java Line 514 java.util.concurrent.FutureTaskrun at FutureTask.java Line 264 java.util.concurrent.ThreadPoolExecutorrunWorker at ThreadPoolExecutor.java Line 1167 java.util.concurrent.ThreadPoolExecutor$Workerrun at ThreadPoolExecutor.java Line 641 java.lang.Threadrun at Thread.java Line 844 * In attach scenario, the remote JVM may be already terminated before ConfigurationDone request. * Avoid to pop up error message to users for vm terminated exception when debug session is actually useless after jvm terminates. * revert changes to handlers. * Remove error notifications to vscode when VMDisconnectedException is happening, since it is normal to have received terminated message during process vscode requests, return an empty response since the debug session is terminated. * fix typo * Merge remote-tracking branch 'origin' into andy_log_attach # Conflicts: # com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java # com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ThreadsRequestHandler.java * merge with async response change for handling VMDisconnectedException * set valid success to VMDisconnectedException * Update ProtocolServer.java * replace complex logic on whenComplete * Merge remote-tracking branch 'origin' into andy_log_attach # Conflicts: # com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProtocolServer.java # com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ThreadsRequestHandler.java
1 parent 645f0dd commit 55e29be

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public List<Disposable> subscriptions() {
6666
// AutoCloseable
6767
@Override
6868
public void close() throws Exception {
69-
vm.eventRequestManager().deleteEventRequests(requests());
69+
try {
70+
vm.eventRequestManager().deleteEventRequests(requests());
71+
} catch (VMDisconnectedException ex) {
72+
// ignore since removing breakpoints is meaningless when JVM is terminated.
73+
}
7074
subscriptions().forEach(subscription -> {
7175
subscription.dispose();
7276
});

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProtocolServer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ProtocolServer extends AbstractProtocolServer {
4242
*/
4343
public ProtocolServer(InputStream input, OutputStream output, IProviderContext context) {
4444
super(input, output);
45-
this.debugAdapter = new DebugAdapter(this, context);
45+
debugAdapter = new DebugAdapter(this, context);
4646
}
4747

4848
/**
@@ -77,7 +77,7 @@ public CompletableFuture<Messages.Response> sendRequest(Messages.Request request
7777
@Override
7878
protected void dispatchRequest(Messages.Request request) {
7979
usageDataSession.recordRequest(request);
80-
this.debugAdapter.dispatchRequest(request).thenCompose((response) -> {
80+
debugAdapter.dispatchRequest(request).thenCompose((response) -> {
8181
CompletableFuture<Void> future = new CompletableFuture<>();
8282
if (response != null) {
8383
sendResponse(response);
@@ -110,5 +110,4 @@ protected void dispatchRequest(Messages.Request request) {
110110
return null;
111111
});
112112
}
113-
114113
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private CompletableFuture<Response> threads(Requests.ThreadsArguments arguments,
7979
Types.Thread clientThread = new Types.Thread(thread.uniqueID(), "Thread [" + thread.name() + "]");
8080
threads.add(clientThread);
8181
}
82-
} catch (VMDisconnectedException | ObjectCollectedException ex) {
82+
} catch (ObjectCollectedException ex) {
8383
// allThreads may throw VMDisconnectedException when VM terminates and thread.name() may throw ObjectCollectedException
8484
// when the thread is exiting.
8585
}
@@ -117,12 +117,8 @@ private CompletableFuture<Response> next(Requests.NextArguments arguments, Respo
117117
private CompletableFuture<Response> pause(Requests.PauseArguments arguments, Response response, IDebugAdapterContext context) {
118118
ThreadReference thread = DebugUtility.getThread(context.getDebugSession(), arguments.threadId);
119119
if (thread != null) {
120-
try {
121-
thread.suspend();
122-
context.getProtocolServer().sendEvent(new Events.StoppedEvent("pause", arguments.threadId));
123-
} catch (VMDisconnectedException ex) {
124-
return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.VM_TERMINATED, "Target VM is already terminated.");
125-
}
120+
thread.suspend();
121+
context.getProtocolServer().sendEvent(new Events.StoppedEvent("pause", arguments.threadId));
126122
} else {
127123
context.getDebugSession().suspend();
128124
context.getProtocolServer().sendEvent(new Events.StoppedEvent("pause", arguments.threadId, true));

0 commit comments

Comments
 (0)