I've been getting this sometimes when I double-click tree nodes in projectviewer to open files.
Not always, just sometimes.
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gjt.sp.jedit.EditBus.dispatch(EditBus.java:253)
at org.gjt.sp.jedit.EditBus.sendImpl(EditBus.java:292)
at org.gjt.sp.jedit.EditBus.access$200(EditBus.java:86)
at org.gjt.sp.jedit.EditBus$SendMessage.run(EditBus.java:466)
at org.gjt.sp.jedit.EditBus.send(EditBus.java:201)
at org.gjt.sp.jedit.Buffer$1.run(Buffer.java:291)
at org.gjt.sp.util.WorkThreadPool.doAWTRequest(WorkThreadPool.java:396)
at org.gjt.sp.util.WorkThreadPool.doAWTRequests(WorkThreadPool.java:381)
at org.gjt.sp.util.WorkThreadPool.access$200(WorkThreadPool.java:39)
at org.gjt.sp.util.WorkThreadPool$RunRequestsInAWTThread.run(WorkThreadPool.java:481)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.NullPointerException
at projectviewer.vpt.ProjectCustomTreeModel.buildPathToRoot(ProjectCustomTreeModel.java:216)
at projectviewer.vpt.ProjectCustomTreeModel.getPathToRoot(ProjectCustomTreeModel.java:134)
at javax.swing.tree.DefaultTreeModel.nodeStructureChanged(DefaultTreeModel.java:347)
at projectviewer.vpt.ProjectCustomTreeModel.addChild(ProjectCustomTreeModel.java:196)
at projectviewer.vpt.VPTWorkingFileListModel.fileOpened(VPTWorkingFileListModel.java:70)
at projectviewer.vpt.ProjectTreePanel.projectFileOpened(ProjectTreePanel.java:407)
at projectviewer.ProjectViewer.handleBufferUpdateMessage(ProjectViewer.java:1085)
at projectviewer.ProjectViewer.handleBufferUpdate(ProjectViewer.java:957)
... 27 more
Attaching a patch which prevents the NPE from happening. Just a null check.
Is it as simple as that?
diff --git a/projectviewer/vpt/ProjectCustomTreeModel.java b/projectviewer/vpt/ProjectCust
index 096aa65..bcdd48f 100644
--- a/projectviewer/vpt/ProjectCustomTreeModel.java
+++ b/projectviewer/vpt/ProjectCustomTreeModel.java
@@ -212,10 +212,12 @@ public abstract class ProjectCustomTreeModel extends ProjectTreeMode
}
}
while (aNode != getRoot()) {
+ if (aNode == null) break;
pathBuilder.add(0, aNode);
aNode = aNode.getParent();
}
- pathBuilder.add(0, aNode);
+ if (aNode != null)
+ pathBuilder.add(0, aNode);
return pathBuilder.toArray(new TreeNode[pathBuilder.size()]);
}
I couldn't attach anything, so I decided to commit directly to git.
Please review the patch.
To ssh://ezust@jedit.git.sourceforge.net/gitroot/jedit/ProjectViewer
2f425c0..6cb515e master -> master
my patch while it gets rid of the NPEs might hide another problem elsewhere, so it should be looked at again.