tm4e icon indicating copy to clipboard operation
tm4e copied to clipboard

ConcurrentModificationException if tm4e used in the context of diff editor

Open iloveeclipse opened this issue 1 year ago • 3 comments

Switching different merge viewers in diff editor can cause following exception (I see it in debugger, not in the error log)

java.util.ConcurrentModificationException
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1229)
	at org.eclipse.tm4e.core.internal.grammar.BasicScopeAttributesProvider.getBasicScopeAttributes(BasicScopeAttributesProvider.java:56)
	at org.eclipse.tm4e.core.internal.grammar.Grammar.getMetadataForScope(Grammar.java:112)
	at org.eclipse.tm4e.core.internal.grammar.AttributedScopeStack._pushAttributed(AttributedScopeStack.java:172)
	at org.eclipse.tm4e.core.internal.grammar.AttributedScopeStack.pushAttributed(AttributedScopeStack.java:157)
	at org.eclipse.tm4e.core.internal.grammar.LineTokenizer.scanNext(LineTokenizer.java:194)
	at org.eclipse.tm4e.core.internal.grammar.LineTokenizer.scan(LineTokenizer.java:131)
	at org.eclipse.tm4e.core.internal.grammar.LineTokenizer.tokenizeString(LineTokenizer.java:565)
	at org.eclipse.tm4e.core.internal.grammar.Grammar._tokenize(Grammar.java:342)
	at org.eclipse.tm4e.core.internal.grammar.Grammar.tokenizeLine(Grammar.java:259)
	at org.eclipse.tm4e.core.model.TMTokenizationSupport.tokenize(TMTokenizationSupport.java:80)
	at org.eclipse.tm4e.core.model.TMModel$TokenizerThread.revalidateTokens(TMModel.java:249)
	at org.eclipse.tm4e.core.model.TMModel$TokenizerThread.run(TMModel.java:172)

Shouldn't org.eclipse.tm4e.core.internal.grammar.BasicScopeAttributesProvider.cache be a ConcurrenthashMap?

On the shell I see this:

Apr 09, 2024 7:02:09 PM org.eclipse.tm4e.core.model.TMModel$TokenizerThread revalidateTokens
SEVERE: java.util.ConcurrentModificationException

iloveeclipse avatar Apr 09 '24 17:04 iloveeclipse

Yes, we can make it a ConcurrentHashMap. The code was originally translated from TypeScript where it runs single threaded.

sebthom avatar Apr 09 '24 18:04 sebthom

Please try out the latest snapshot.

sebthom avatar Apr 09 '24 20:04 sebthom

Please try out the latest snapshot.

Looks good so far.

BTW, I've pimped SDK so the Textmate works now also by default in compare editor, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/1747

iloveeclipse avatar Apr 10 '24 12:04 iloveeclipse

TM4E 0.12.0 incorporating the fix released

sebthom avatar May 21 '24 09:05 sebthom