Skip to content

Fix ConcurrentModificationException in CompletionProvider listener iteration#13

Merged
ethanyhou merged 2 commits into
mainfrom
copilot/fix-internal-error-generating-completion
Apr 20, 2026
Merged

Fix ConcurrentModificationException in CompletionProvider listener iteration#13
ethanyhou merged 2 commits into
mainfrom
copilot/fix-internal-error-generating-completion

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

CompletionProvider.notifyCompletionResolved iterates completionListeners on the completion job worker thread, while addCompletionListener / removeCompletionListener can mutate the set from other threads. Backing it with a plain LinkedHashSet produced the ConcurrentModificationException reported in the issue:

java.util.ConcurrentModificationException
    at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(...)
    at CompletionProvider$CompletionJob.notifyCompletionResolved(CompletionProvider.java:289)
    at CompletionProvider$CompletionJob.run(CompletionProvider.java:170)

Changes

  • CompletionProvider.java: switch completionListeners from LinkedHashSet to CopyOnWriteArraySet. Iteration is snapshot-based and safe under concurrent add/remove, which fits a read-heavy listener collection and aligns with the project's convention of using copy-on-write collections for concurrent listener access.
// before
this.completionListeners = new LinkedHashSet<>();
// after
this.completionListeners = new CopyOnWriteArraySet<>();

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-8a343ad76595886d/dbs/java/working/files-to-index11279688604168215133.list --sourceArchiveDir=/tmp/codeql-scratch-8a343ad76595886d/dbs/java/src --outputDir=/tmp/codeql-scratch-8a343ad76595886d/dbs/java/trap/java (dns block)
  • www.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -classpath /home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/boot/plexus-classworlds-2.8.0.jar -Dclassworlds.conf=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/bin/m2.conf -Dmaven.home=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1 -Dlibrary.jansi.path=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/copilot-for-eclipse/copilot-for-eclipse org.codehaus.plexus.classworlds.launcher.Launcher -pl com.microsoft.copilot.eclipse.core -am compile -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

fixes microsoft/copilot-eclipse-feedback#181

Copilot AI changed the title [WIP] Fix internal error during completion generation in Copilot plugin Fix ConcurrentModificationException in CompletionProvider listener iteration Apr 18, 2026
Copilot AI requested a review from jdneo April 18, 2026 09:08
@jdneo jdneo marked this pull request as ready for review April 18, 2026 10:45
Copy link
Copy Markdown
Contributor

@ethanyhou ethanyhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ethanyhou ethanyhou merged commit 079b452 into main Apr 20, 2026
4 checks passed
@ethanyhou ethanyhou deleted the copilot/fix-internal-error-generating-completion branch April 20, 2026 01:46
@jdneo jdneo mentioned this pull request May 7, 2026
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An internal error occurred during: "Generating completion...".

3 participants