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 49226 - NPE after renaming src folder
Summary: NPE after renaming src folder
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-18 04:13 UTC by Pavel Fiala
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
fixed RepositoryUpdater (14.07 KB, patch)
2004-09-18 04:20 UTC, Pavel Fiala
Details | Diff
Stack trace (10.14 KB, text/plain)
2004-09-20 12:53 UTC, Pavel Fiala
Details
diff (2.50 KB, patch)
2004-09-20 12:54 UTC, Pavel Fiala
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Fiala 2004-09-18 04:13:35 UTC
1. Create new java application
2. Select window Files and browse to folder "src"
of the application
3. Rename it
--> a NPE is thrown

It is caused by error in method folderRenamed() of
org.netbeans.modules.javacore.RepositoryUpdater

The method should be changed as follows:

    private void folderRenamed(FileRenameEvent fe) {
        FileObject newFo = fe.getFile();
        boolean failed = true;
        
       
JMManager.getDefaultRepository().beginTrans(true);
        try {
            Enumeration children =
newFo.getChildren(true);
            FileObject cpRoot = getCPRoot(newFo);
            if (cpRoot == null) {
                // ignore folders that are not
visible from our merged classpath
                return;
            }
            String dirName =
JMManager.getResourceName(cpRoot, newFo);
            while (children.hasMoreElements()) {
                FileObject f = (FileObject)
children.nextElement();
                if ("java".equals(f.getExt()) &&
!f.isVirtual()) { // NOI18N
                    String oldName =
JMManager.getResourceName(cpRoot, f);
                    String newName =
replaceStart(oldName, dirName, fe.getName());
                    newName = replaceEnd(dirName,
fe.getName());
                    newName =
replaceStart(oldName, dirName, newName);
                    if (DEBUG)
                        System.out.println("Folder
renamed: Resource " + newName + " renamed to " +
oldName); // NOI18N
                    manager.getResource(cpRoot,
oldName).setName(newName);
                }
            }
            failed = false;
        } finally {
           
JMManager.getDefaultRepository().endTrans(failed);
        }
    }
Comment 1 Pavel Fiala 2004-09-18 04:20:47 UTC
Created attachment 17721 [details]
fixed RepositoryUpdater
Comment 2 Jan Becicka 2004-09-20 07:45:27 UTC
Thanks for the fix, but please:
1. Attach stack trace of the NPE
2. If you are attaching patches, don't attach whole files, but only
diffs (-u)




Comment 3 Pavel Fiala 2004-09-20 12:53:23 UTC
Created attachment 17753 [details]
Stack trace
Comment 4 Pavel Fiala 2004-09-20 12:54:58 UTC
Created attachment 17754 [details]
diff
Comment 5 Jan Becicka 2004-09-20 14:10:37 UTC
Thanks for attachments.

Fixed.
Checking in RepositoryUpdater.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/RepositoryUpdater.java,v
 <--  RepositoryUpdater.java
new revision: 1.19; previous revision: 1.18
done
Comment 6 Jiri Prox 2005-07-12 11:45:15 UTC
Verified in 4.2 (200507110943)
Comment 7 Quality Engineering 2007-09-20 09:44:44 UTC
Reorganization of java component