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

Bug 336936

Summary: NPE in ProjectHelper$LexHandler.comment when reconciling Ant file
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: AntAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: aniefer, Michael_Rennie
Version: 3.7   
Target Milestone: 3.7 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix none

Description Markus Keller CLA 2011-02-11 08:50:34 EST
I20110208-0800

- new workspace, new project, new File "build.xml"
- Ctrl+Space, choose first proposal "Buildfile template"
- Save
- put caret on the comment line containing the creation date / time
- Ctrl+D
=> NPE in log. The same NPE is also thrown whenever I save the file after doing minor edits.

!ENTRY org.eclipse.ant.ui 4 120 2011-02-11 14:47:58.673
!MESSAGE Error logged from Ant UI:
!STACK 0
java.lang.NullPointerException
        at org.eclipse.ant.internal.ui.editor.utils.ProjectHelper$LexHandler.comment(ProjectHelper.java:477)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.comment(AbstractSAXParser.java:667)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.comment(XMLDTDValidator.java:978)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:479)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at org.eclipse.ant.internal.ui.editor.utils.ProjectHelper.parse(ProjectHelper.java:588)
        at org.eclipse.ant.internal.ui.editor.utils.ProjectHelper.parse(ProjectHelper.java:653)
        at org.eclipse.ant.internal.ui.model.AntModel.parseDocument(AntModel.java:344)
        at org.eclipse.ant.internal.ui.model.AntModel.reconcile(AntModel.java:291)
        at org.eclipse.ant.internal.ui.editor.text.XMLReconcilingStrategy.internalReconcile(XMLReconcilingStrategy.java:43)
        at org.eclipse.ant.internal.ui.editor.text.XMLReconcilingStrategy.reconcile(XMLReconcilingStrategy.java:56)
        at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
        at org.eclipse.ant.internal.ui.editor.text.NotifyingReconciler.process(NotifyingReconciler.java:39)
        at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 1 Markus Keller CLA 2011-02-11 09:04:42 EST
Note that the Error Log view is not reliable in this build, see bug 336938.
Comment 2 Michael Rennie CLA 2011-02-11 12:14:28 EST
Simplified steps:

1. open / create any Ant buildfile with a comment
2. Ctrl+D one of the lines of the comment

The problem is coming from our custom implementation of Project#getReferences(). With the update to Ant 1.8.2 I broke a subtlety where the map of references returned from Project#getReferences() must be the live map for the project, so that removals from the map actually affect the project.
Comment 3 Michael Rennie CLA 2011-02-11 13:32:43 EST
Created attachment 188803 [details]
fix

The patch corrects the getReferences() behavior and adds regression tests for AntModelProject
Comment 4 Michael Rennie CLA 2011-02-11 15:29:34 EST
*** Bug 336994 has been marked as a duplicate of this bug. ***
Comment 5 Michael Rennie CLA 2011-02-11 16:42:46 EST
applied patch to HEAD