This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 170415

Summary: java.util.ConcurrentModificationException: Caller uses obsolete token sequence which is no longer valid. Underlying token hierarchy has been modified: modCount=10 != upToDateModCount=13 Please report
Product: contrib Reporter: Jan Lahoda <jlahoda>
Component: CodeAssignee: Michel Graciano <hmichel>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=155923
Issue Type: DEFECT Exception Reporter: 155923
Attachments: stacktrace

Description Jan Lahoda 2009-08-15 19:11:23 UTC
Build: NetBeans IDE Dev (Build jet-main-1129-on-090814)
VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.28-11-generic, i386

Stacktrace: 
java.util.ConcurrentModificationException: Caller uses obsolete token sequence which is no longer valid. Underlying token hierarchy has been modified: modCount=10 != upToDateModCount=13
Please report against caller's module which needs to be fixed (not the lexer module).
        at org.netbeans.api.lexer.TokenSequence.checkModCount(TokenSequence.java:745)
        at org.netbeans.api.lexer.TokenSequence.moveNext(TokenSequence.java:451)
        at org.netbeans.modules.showtodos.TodoSourceParsing.parse(TodoSourceParsing.java:97)
        at org.netbeans.modules.showtodos.TodoSourceParsing.parseForAnnotatable(TodoSourceParsing.java:132)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider.parse(TodoAnnotationProvider.java:121)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider.annotate(TodoAnnotationProvider.java:107)
Comment 1 Jan Lahoda 2009-08-15 19:11:30 UTC
Created attachment 86272 [details]
stacktrace
Comment 2 Michel Graciano 2009-08-15 23:44:37 UTC
Do you have any details about what was you doing (removing several lines or typing) and which project was you editing 
(maybe an nb module)? Thanks for your report
Comment 3 Michel Graciano 2009-08-16 00:58:53 UTC
Which plugin version are you using? AFAIK you probably are running the latest version.
Comment 4 Michel Graciano 2009-08-16 01:06:11 UTC
Should be fixed.

main/contrib: #15434:a56da5322d8e
Comment 5 Jan Lahoda 2009-08-16 15:32:24 UTC
I did some editing. Most likely some more complex operation, like indent/un-indent, which are internally split into
several operations. apisupport project, but that should not matter, IMO. The used version of the module can be found in
the log, which is available in the exceptions report:
http://statistics.netbeans.org/exceptions/messageslog?id=244091
The version is:
org.netbeans.modules.showtodos [2.4.0.1 nbms-and-javadoc-3567-on-090721]

Sorry, but I do not think that the fix is fully correct - the problem is that the TokenSequence is used outside read (or
write) lock on the Document. Calling isValid() will make the exception less probable, but not impossible. Would be
better to do the operations under the document read lock [Document.reander()] (possibly locking it each time the finder
finds something and checking isValid() once immediately after read-locking the document). Might be also possible to do
the work in parsing.api's task, using the copy of the document text provided by the parsing.api and carefully handling
cancel, in order to prevent highlighting incorrect parts of the document.
Comment 6 Michel Graciano 2009-08-16 21:22:42 UTC
Thanks for the tips. I will try to rewrite it with mentioned API asap. BTW, if you can point me to some module that uses 
parsing api's task? Thanks again for your help.