United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6671481 NPE at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection
JDK-6671481 : NPE at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection

Details
Type:
Bug
Submit Date:
2008-03-05
Status:
Closed
Updated Date:
2013-06-26
Project Name:
JDK
Resolved Date:
2013-04-26
Component:
client-libs
OS:
windows_8,linux,windows_7
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u3,7u6
Fixed Versions:
6u60 (b01)

Related Reports
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
NPE in BasicTreeUI:

java.lang.NullPointerException
        at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3501)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.mouseReleasedDND(BasicTreeUI.java:3571)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.mouseReleased(BasicTreeUI.java:3559)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(LightweightDispatcher.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(LightweightDispatcher.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(LightweightDispatcher.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at org.netbeans.core.TimeableEventQueue.dispatchEvent(TimeableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

I examined the code and it looks like getPathBounds(tree, pressedPath) returns null (don't know why and how) and then NPE arises:

                Rectangle bounds = getPathBounds(tree, pressedPath);

line 3501: NPE:     if(e.getY() >= (bounds.y + bounds.height)) {
                    return;
                }


Happens in NetBeans IDE, original issue is here:
http://www.netbeans.org/issues/show_bug.cgi?id=126170

Nice summarization of when error appeared to users can be seen here:
http://statistics.netbeans.org/analytics/detail.do?id=2534

                                    

Comments
EVALUATION

It is very difficult to work with a bug without any test case,
There are two cases when BasicTreeUI.getPathBounds() can return null:

	if(tree != null && treeState != null) {
            return getPathBounds(path, tree.getInsets(), new Rectangle());
	}
	return null;

At least we need to know if the tree or treeState is null when NPE arises
(runnable test case would be ideal)

asked submitter for more information
                                     
2008-03-14
EVALUATION

I understand, it is difficult to fight with random and rarely reproducible bugs, we are in the same state here in NetBeans team.

Unfortunately, I'm not able to produce test case for you - issue never happened on my machine and I don't know how to simulate it. However, in such situations "defensive" fix looks enough for me - if you are checking for null from getBounds on other places, just check once more, anything is better then exception. I know that it may just hide real source of error, but I don't have better idea, sorry.
                                     
2008-03-19
Raising priority and adding 7u9 and 7u10 amongst affected versions.

Even though the similar bug JDK-6505523 was closed fixed in 7u4 and 6u38, there are more duplicates gathering against NetBeans.

See
http://statistics.netbeans.org/exceptions/detail.do?id=2534
http://statistics.netbeans.org/exceptions/detail.do?id=193286
                                     
2012-11-06
Justification: Deferred as failed in 6u3 - will work to resolve (Fix/Close - with SQE agreement) by the end of Dec/2012.
                                     
2012-11-19
SQE is OK to defer this
                                     
2012-11-19
  I do not know steps to reproduce the issue, but the fixed issue 6505523 can shed light on this mysterious NPE.
   It is reproduced when drag is enabled and a node is removed by an expansion listener.
   The pressed path is stored in the BasicTreeUI during mouse pressed event. Then the expansion listener removes the path
   and the mouse released event checks the stored path by the getPathBounds() method and gets null (the path has been already removed). 
                                     
2012-11-26



Hardware and Software, Engineered to Work Together