Community
Participate
Working Groups
Build Identifier: M20110909-1335 In Xtext 2.2.1, a NPE occurs in DefaultOccurrenceComputer.createAnnotationMap(DefaultOccurrenceComputer.java:86), when dereferencing the document that has been just retrieved from the editor. It probably occurred because the document has been closed after the MarkOccurrenceJob has been schedule, but before the job has been actually run. If the document is null, it is seems safe to cancel the operation. !MESSAGE An internal error occurred during: "Mark Occurrences". !STACK 0 java.lang.NullPointerException at org.eclipse.xtext.ui.editor.occurrences.DefaultOccurrenceComputer.createAnnotationMap(DefaultOccurrenceComputer.java:86) at org.eclipse.xtext.ui.editor.occurrences.OccurrenceMarker$MarkOccurrenceJob.run(OccurrenceMarker.java:122) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Reproducible: Sometimes
The stacktrace does not match the latest version from master. Any chance to reproduce the problem?
I think it is a concurrency issue, so it is not easy to reproduce. Maybe I could try to reproduce it on the version from the master with some breakpoints. Is the master publicly accessible ?
The udpate site with the latest successful build is available here: https://hudson.eclipse.org/hudson/job/Xtext-nightly-HEAD/lastSuccessfulBuild/artifact/xtext.p2.repository/
In the version of Xtext 2.3.0v201201121125, the line at which the error may occur is line 80. I am now trying to reproduce the bug.
To reproduce the bug, 1) put a breakpoint on line 79 in DefaultOccurrenceComputer (at editor.getDocument();), 2) open an editor and have the cursor on a reference with Mark Occurrences activated to reach the breakpoint, 3) once the job is waiting at the breakpoint, close the editor, and 4) resume the job that was waiting (editor contains a null document, and this produces an NPE at the next line)
Alright, that's evil: as createAnnotationMap is not called from the UI thread (deliberately, to do the calcultion in background) the editor could have disposed its document in the meantime. Pushed a NPE guard.
Closing all bugs that were set to RESOLVED before Neon.0