Skip to content

Commit

Permalink
[DAP] Only need to add completion listener to main module
Browse files Browse the repository at this point in the history
The language-specific debuggers are the ones responsible for copying over execution
listeners when we cross language boundaries. This avoids one risk related to concurrent
modifications and accesses of the execution listeners.
  • Loading branch information
agarciadom committed Aug 28, 2024
1 parent e92c919 commit a5b5103
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,6 @@ protected ThreadState attachTo(IEolModule module) {
module.getContext().getExecutorFactory().setExecutionController(thread.debugger);
}

// Attach the completion listener to this module, if we haven't done so yet
boolean hasListener = false;
for (IExecutionListener l : module.getContext().getExecutorFactory().getExecutionListeners()) {
if (l == completionListener) {
hasListener = true;
break;
}
}
if (!hasListener) {
module.getContext().getExecutorFactory().addExecutionListener(completionListener);
}

// Attach to the module's output and error streams
final PrintStream outStream = createStream(module.getContext(), OutputEventArgumentsCategory.STDOUT);
module.getContext().setOutputStream(outStream);
Expand Down Expand Up @@ -397,6 +385,7 @@ public void connect(IDebugProtocolClient client) {
throw new IllegalStateException("connect(): the module has not been set up yet");
}
attachTo(mainModule);
mainModule.getContext().getExecutorFactory().addExecutionListener(completionListener);

this.client = client;
client.initialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public final StackTraceManager getStackTraceManager() {

public void addExecutionListener(IExecutionListener listener) {
if (executionListeners == null) {
executionListeners = new CopyOnWriteArrayList<>();
executionListeners = new ArrayList<>(1);
}
executionListeners.add(listener);
}
Expand Down

0 comments on commit a5b5103

Please sign in to comment.