This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 25229 - NPE when removing folders from Java Sources component
Summary: NPE when removing folders from Java Sources component
Status: CLOSED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-27 11:35 UTC by Milan Kubec
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
exc stack trace (1.17 KB, text/plain)
2002-06-27 11:35 UTC, Milan Kubec
Details
exc stack trace (7.23 KB, text/plain)
2002-07-16 15:18 UTC, Milan Kubec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2002-06-27 11:35:19 UTC
I got NullPointerException when removing two
folders from Java Sources component, but I cannot
reproduce it. Exc is attached.
Comment 1 Milan Kubec 2002-06-27 11:35:45 UTC
Created attachment 6467 [details]
exc stack trace
Comment 2 Vitezslav Stejskal 2002-07-01 13:50:46 UTC
Target Milestone -> 4.0
Comment 3 Milan Kubec 2002-07-16 15:15:58 UTC
Happened to me also when adding existing folders to Java Sources
component. Exceptions are attached.
Comment 4 Milan Kubec 2002-07-16 15:18:30 UTC
Created attachment 6728 [details]
exc stack trace
Comment 5 Torbjorn Norbye 2002-07-16 15:25:13 UTC
I suspec this is the same root cause as 25350.  Removing
the folder does not happen immediately, and after the removal
the AWT event thread decides to refresh the UI, so it eventually
calls getDisplayName. But getDisplayName eventually calls
Project.find(obj) - which eventually returns null (because
the object has been removed from the project).  However,
from a cursory look at CPRootLook.java it seems the code
assumes Project.find() will never return null.
Comment 6 Torbjorn Norbye 2002-07-16 15:52:17 UTC
Well, there's another way to reproduce this problem too
(actually, it may not be the same problem, but it has
nearly identical stacktrace).

I simply opened two projects which have a "conflict"
in the sense that the same source directory is used
in both projects. Simply drilling down and attempting
to open the "Java Sources" node causes the exception
to be thrown. It should also be noted that you get the
CLASH!!! warning which is printed by Project.java before
it returns null for Project.find. Thus, the end result
is the same (null in getDisplayName which is then
dereferenced) yet the cause here is different; we're
not removing anything. The solution is for CPRootLook
to check the result of Project.find.

--- CPRootLook.java	26 Jun 2002 19:11:49 -0000	1.1.2.3
+++ CPRootLook.java	16 Jul 2002 14:51:49 -0000
@@ -66,7 +66,11 @@
                 name = e.getMessage ();
             }
         } else {
-            DataObject homes [] = Project.find (root.getFolder
()).getBaseDirs ().getChildren ();
+            Project p = Project.find (root.getFolder ());
+
    if (p == null) {
+
	return ""; // Fixes exception, but what to use instead???
+
    }
+            DataObject homes [] = p.getBaseDirs ().getChildren ();
 
             for (int i = 0; i < homes.length; i++) {
Comment 7 Torbjorn Norbye 2002-07-16 15:58:03 UTC
By the way, let me point out that I didn't intend
to imply that the above was a complete fix; we (projects)
need to finish our dataobject->project data object
lookup such that we compute the right project context
to be used by Project.find() since it shouldn't return
null in the case it currently is. CPRootLook still needs
to check for null in the case of deferred removal of
nodes, but for the case where a project is included in 
multiple projects, Project.find should not return null,
it should return a project (and preferably the RIGHT
project. Since this is from a look which has an associated
node, we can probably find the correct project.)
Comment 8 Torbjorn Norbye 2002-07-16 17:11:33 UTC
I've changed it such that Project.find() returns the first
found project rather than null when there are multiple
eligible projects. Transferring to the java module for
the rest of the work to get done.
Comment 9 Tomas Hurka 2002-12-06 12:15:27 UTC
It seems to be fixed. I cannot reproduce it. 
Comment 10 Milan Kubec 2003-08-18 09:12:58 UTC
Verified.
Comment 11 Jan Becicka 2003-11-25 14:20:29 UTC
As described in
http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss the
current work on projects prototype has been stopped.

Marking issue as CLOSED.