Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"sourcePaths": [
"${workspaceRoot}/com.microsoft.java.debug.core/main/java",
"${workspaceRoot}/com.microsoft.java.debug.plugin/src/main/java"
]
],
"projectName": "com.microsoft.java.debug.plugin"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ public interface IProvider {
*/
default void initialize(IDebugAdapterContext debugContext, Map<String, Object> options) {
}

/**
* Close the provider and free all associated resources.
*/
default void close() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.microsoft.java.debug.core.Configuration;
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
import com.microsoft.java.debug.core.adapter.IDebugRequestHandler;
import com.microsoft.java.debug.core.adapter.IHotCodeReplaceProvider;
import com.microsoft.java.debug.core.adapter.LaunchMode;
import com.microsoft.java.debug.core.protocol.Messages.Response;
import com.microsoft.java.debug.core.protocol.Requests.Arguments;
Expand Down Expand Up @@ -50,6 +51,7 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
* @param context the debug context
*/
private void destroyResource(IDebugAdapterContext context) {
destroyProviders(context);
if (shouldDestroyLaunchFiles(context)) {
destroyLaunchFiles(context);
}
Expand Down Expand Up @@ -97,4 +99,11 @@ private void destroyLaunchFiles(IDebugAdapterContext context) {
}

protected abstract void destroyDebugSession(Command command, Arguments arguments, Response response, IDebugAdapterContext context);

protected void destroyProviders(IDebugAdapterContext context) {
IHotCodeReplaceProvider hcrProvider = context.getProvider(IHotCodeReplaceProvider.class);
if (hcrProvider != null) {
hcrProvider.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ public void destroyDebugSession(Command command, Arguments arguments, Response r
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,16 @@ public void initialize(IDebugAdapterContext context, Map<String, Object> options
}
this.context = context;
currentDebugSession = context.getDebugSession();
}

@Override
public void close() {
if (DebugSettings.getCurrent().hotCodeReplace != DebugSettings.HotCodeReplace.NEVER) {
// Remove the listener.
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
}

// TODO: Change IProvider interface for shutdown event
eventSubject.onComplete();
}

@Override
Expand Down