Skip to content

ContributionContextTypeRegistry is not thread-safe #4020

@trancexpress

Description

@trancexpress

In our automated tests, we see such logged errors:

!ENTRY org.eclipse.egit.ui 4 0 2026-05-21 01:52:19.697
!MESSAGE Cannot register git support for Java templates
!STACK 0
java.util.ConcurrentModificationException
	at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:1024)
	at java.base/java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:1053)
	at org.eclipse.egit.ui.internal.StartEventListener.lambda$2(StartEventListener.java:108)
	at org.eclipse.egit.ui.internal.StartEventListener.lambda$0(StartEventListener.java:70)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5084)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4549)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1147)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1038)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:677)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:583)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)

We started seeing the errors after activating the org.eclipse.jdt.ls.core early in our tests life-cycle.

JDT LS has initialization code that uses:

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java:                ContextTypeRegistry registry = JavaManipulation.getCodeTemplateContextRegistry();

EGit likewise, as seen in the stack trace above.

Since multiple clients want to initialize templates during their respective bundle activation, we need guidance on what needs to change in the respective bundles, or thread-safety in ContributionContextTypeRegistry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions