Bug 126673

Summary: NPE in Buffer.addBufferChangedListener
Product: [Eclipse Project] JDT Reporter: Tim Hanson <thanson>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed Patch none

Description Tim Hanson CLA 2006-02-06 20:21:14 EST
When running internal tests, we encountered the following intermittent stack trace:

     [java] java.lang.NullPointerException
     [java]     at org.eclipse.jdt.internal.core.Buffer.addBufferChangedListener(Buffer.java:62)
     [java]     at org.eclipse.jdt.internal.core.CompilationUnit.openBuffer(CompilationUnit.java:1023)
     [java]     at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:263)
     [java]     at org.eclipse.jdt.internal.core.CompilationUnit.getContents(CompilationUnit.java:581)
     [java]     at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:748)
     [java]     at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588)
     [java]     at com.bea.wlw.common.core.ast.ReaderUtil.parse(ReaderUtil.java:74)
     [java]     at com.bea.wlw.netui.core.page.model.PageStructureBuilder.build(PageStructureBuilder.java:142)
     [java]     at com.bea.wlw.common.core.model.AbstractExternalEventAdapter$StructureBuilderJob.run(AbstractExternalEventAdapter.java:256)
     [java]     at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)

It appears that there is one unsynchronized write to the field Buffer.changeListeners inside of the method Buffer.close()
Comment 1 Tim Hanson CLA 2006-02-06 20:36:54 EST
Created attachment 34253 [details]
Proposed Patch

This just synchronizes around the write to this.changeListeners in close()
Comment 2 Jerome Lanneluc CLA 2006-02-07 10:07:12 EST
Thanks for the patch, Tim. Released it in HEAD.
Comment 3 Frederic Fusier CLA 2006-02-14 11:18:28 EST
Code verified for 3.2 M5 using build I20060214-0010.