Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368528 - NPE in Mark Occurrences because of a null document
Summary: NPE in Mark Occurrences because of a null document
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-13 05:24 EST by Laurent CLA
Modified: 2017-09-19 17:36 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent CLA 2012-01-13 05:24:09 EST
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
Comment 1 Sebastian Zarnekow CLA 2012-01-13 05:30:16 EST
The stacktrace does not match the latest version from master.

Any chance to reproduce the problem?
Comment 2 Laurent CLA 2012-01-13 05:45:53 EST
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 ?
Comment 3 Sebastian Zarnekow CLA 2012-01-13 05:47:38 EST
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/
Comment 4 Laurent CLA 2012-01-13 06:10:44 EST
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.
Comment 5 Laurent CLA 2012-01-13 06:18:54 EST
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)
Comment 6 Jan Koehnlein CLA 2012-01-17 09:04:52 EST
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.
Comment 7 Karsten Thoms CLA 2017-09-19 17:24:47 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 8 Karsten Thoms CLA 2017-09-19 17:36:28 EDT
Closing all bugs that were set to RESOLVED before Neon.0