Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347443 - NPE during Xtext validation
Summary: NPE during Xtext validation
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 349990 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-27 08:56 EDT by Andreas Muelder CLA
Modified: 2017-09-19 17:42 EDT (History)
3 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Muelder CLA 2011-05-27 08:56:38 EDT
Build Identifier: I20110519-1138

An NPE is thrown when a grammar is opened that is not as a file in the workspace.


java.lang.NullPointerException
	at org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.updateMarkerAnnotations(AnnotationIssueProcessor.java:170)
	at org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.processIssues(AnnotationIssueProcessor.java:72)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Reproducible: Always

Steps to Reproduce:
1. Create a new grammar derived from xbase
2. open the base grammar with CTRL + click on xbase
3. Execute a clean build
Comment 1 Jan Koehnlein CLA 2011-07-06 10:14:59 EDT
Cannot reproduce this. Please reopen if this bug reappears.
Comment 2 Andreas Muelder CLA 2011-07-06 10:36:55 EDT
Hi Jan,
I reopened because I can reproduce this issue on different machines. Maybe this is a platform dependend problem, do you need log files or something?
Greets,
Andreas
Comment 3 Jan Koehnlein CLA 2011-07-06 11:18:13 EDT
Yes, a log would be helpful, even though this beging to appear a race condition thing. I tried with both, a new project and the domainmodel example on a Mac and everything worked fine.

But I remember having seen a similar exception before. Maybe we should just add a NPE guard for a missing annotationModel.
Comment 4 Jan Koehnlein CLA 2011-07-06 11:23:34 EDT
If you add a breakpoint in org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor.modelChanged(IAnnotationModel)
is the passed in model = null or is it the same as the field annotationModel??
Comment 5 Sebastian Zarnekow CLA 2011-07-06 11:49:49 EDT
Since #getAnnotationsToRemove has this guard

if (monitor.isCanceled() || annotationModel == null) {
  return Lists.newArrayList();
}

I'd assume that the annotation model may be null. We should probably move the guard to #processIssues ?
Comment 6 Andreas Muelder CLA 2011-07-06 12:32:10 EDT
If a grammar file outside the workspace is opened, XtextReadonlyEditorInput is used. This implements IStorageEditorInput instead of IFileEditorInput. Thus,
the StorageDocumentProvider is used instead of the FileDocumentProvider and 
StorageDocumentProvider#createAnnotationModel simply returns null.
Thus, null is passed to the constructor of the AnnotationIssueProcessor. 

I don't know whats the best solution - let XtextReadonlyEditorInput implement IFileEditorInput or add some null checks in the AnnotationIssueProcessor?
Comment 7 Jan Koehnlein CLA 2011-07-07 05:45:34 EDT
FInally I could reproduce it: It does not occur if you open a file from the original workspace from a runtime Eclipse, as the folders are linked such that IFiles can be used...

To run validation on an editor without an annotation model doesn't make sense, neither does an AnnotationIssueProcessor without annotation model. I added a guard in the XtextDocumentProvider and explicitly throw an exception when someone tries to instantiate an AIP without annotation model.

Pushed to MASTER.
Comment 8 Sebastian Zarnekow CLA 2011-07-12 16:49:47 EDT
*** Bug 349990 has been marked as a duplicate of this bug. ***
Comment 9 Karsten Thoms CLA 2017-09-19 17:31:02 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 10 Karsten Thoms CLA 2017-09-19 17:42:13 EDT
Closing all bugs that were set to RESOLVED before Neon.0