Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354051

Summary: textInputListener from OutlinePage is unsafe
Product: [Modeling] TMF Reporter: Samantha Chan <chanskw>
Component: XtextAssignee: Jan Koehnlein <jan>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jan, karsten.thoms, mkomor, sebastian.zarnekow, tmf.xtext-inbox
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Samantha Chan CLA 2011-08-05 15:33:01 EDT
In this code here:

	textInputListener = new ITextInputListener() {
			public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
				try {
					xtextDocument.removeModelListener(modelListener);
					xtextDocument = XtextDocumentUtil.get(newInput);
					xtextDocument.addModelListener(modelListener);
					scheduleRefresh();
				} catch (Throwable t) {
					LOG.error("Error refreshing outline", t);
				}
			}
			
			public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
			}
		};

XTextDocumentUtil.get(newInput) can return null as the xtextDocument.  We use the XtextDocument object without checking the return value, causing NPE to happen.
Comment 1 Samantha Chan CLA 2011-08-10 11:41:55 EDT
Is it possible to target this for the next 2.0 SR?

Thanks!
Comment 2 Sebastian Zarnekow CLA 2011-08-16 17:11:15 EDT
Scheduled for 2.1
Comment 3 Jan Koehnlein CLA 2011-08-29 12:01:52 EDT
*** Bug 345388 has been marked as a duplicate of this bug. ***
Comment 4 Jan Koehnlein CLA 2011-08-30 11:07:59 EDT
Added a couple of NPE guards. 

I'd like to provide a test, too, but I can't figure out how to reproduce the NPE. Can you give me a hint?
Comment 5 Sebastian Zarnekow CLA 2011-09-30 04:41:02 EDT
(In reply to comment #4)
> I'd like to provide a test, too, but I can't figure out how to reproduce the
> NPE. Can you give me a hint?

Ping.
Comment 6 Jan Koehnlein CLA 2011-10-26 09:32:51 EDT
As there was no hint how to test this, I am closing this without a test.
Comment 7 Karsten Thoms CLA 2017-09-19 17:21:14 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 8 Karsten Thoms CLA 2017-09-19 17:32:38 EDT
Closing all bugs that were set to RESOLVED before Neon.0