Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311384 - NPE toggling breakpoints
Summary: NPE toggling breakpoints
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Pawel Piech CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-03 11:22 EDT by Michael Rennie CLA
Modified: 2010-05-03 16:15 EDT (History)
2 users (show)

See Also:
darin.eclipse: review+


Attachments
Fix. (10.87 KB, patch)
2010-05-03 14:31 EDT, Pawel Piech CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2010-05-03 11:22:13 EDT
build: I20100429-1549

using the following test source I had watchpoints on all of the fields and proceeded to toggle them all from the editor, when I got to the third one I got the following exception.

public class Foo {
    int d;
    int b;
    int c;
}


At the time the breakpoints view was visible and was showing grouped by breakpoint type.

java.lang.NullPointerException
at org.eclipse.debug.ui.BreakpointTypeCategory.equals(BreakpointTypeCategory.java:70)
at org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer.equals(BreakpointContainer.java:616)
at java.util.ArrayList.indexOf(ArrayList.java:220)
at org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer.addBreakpoint(BreakpointContainer.java:296)
at org.eclipse.debug.internal.ui.model.elements.BreakpointManagerContentProvider$InputData.createRootContainer(BreakpointManagerContentProvider.java:680)
at org.eclipse.debug.internal.ui.model.elements.BreakpointManagerContentProvider$InputData.<init>(BreakpointManagerContentProvider.java:149)
at org.eclipse.debug.internal.ui.model.elements.BreakpointManagerContentProvider.getInputData(BreakpointManagerContentProvider.java:927)
at org.eclipse.debug.internal.ui.model.elements.BreakpointManagerContentProvider.getChildCount(BreakpointManagerContentProvider.java:963)
at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildCount(ElementContentProvider.java:114)
at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$2.run(ElementContentProvider.java:63)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Pawel Piech CLA 2010-05-03 14:31:08 EDT
Created attachment 166828 [details]
Fix.

There's a couple of interesting things in this bug.  One issue, is a simple one in that the JavaBreakpointTypeAdapterFactory creates BreakpointTypeContainer objects with a null type.  Fixing this bug means that breakpoints which do not have a type will be categorized as "Other".  This can happen if the breakpoint marker is already disposed when the content provider looks at it. 

However, after fixing this the view shows another anomaly: some breakpoints added as "Other" are never removed from the view.  After debugging this I traced it to the fact that the added/removed events are being sent in the wrong order when the BPs are added/removed really fast.  I don't know the exact reason for this, but I suspect that it's due to the fact that BP events are generated upon a workbench build event, and not immediately after a resource change.  

The workaround in this patch (cumulative with bug 310879 and bug 311236) is to add a test when processing breakpointsAdded event to check whether the BP is already removed.
Comment 2 Darin Wright CLA 2010-05-03 16:15:28 EDT
+1 for bug & patch. Applied/Fixed.