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 157707 - CCE from MultiBundleStructure.getNthEntry
Summary: CCE from MultiBundleStructure.getNthEntry
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Properties (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Alexey Butenko
URL: http://statistics.netbeans.org/except...
Keywords: REGRESSION, SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2009-01-31 18:33 UTC by Jesse Glick
Modified: 2009-02-19 22:57 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 145747


Attachments
stacktrace (4.82 KB, text/plain)
2009-01-31 18:34 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-01-31 18:33:56 UTC
Build: NetBeans IDE Dev (Build 090131)
VM: Java HotSpot(TM) Client VM, 1.5.0_15-b04, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_15-b04
OS: Linux, 2.6.27-11-generic, i386

User Comments:
jglick: Find in Files, matching a *.properties file.



Stacktrace: 
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:0)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.netbeans.modules.search.Manager$1.run(Manager.java:440)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
Comment 1 Jesse Glick 2009-01-31 18:34:01 UTC
Created attachment 76411 [details]
stacktrace
Comment 2 Jesse Glick 2009-01-31 18:48:43 UTC
Probable regression from recent changes to properties module. Prevented me from opening a project.properties file at
all. Maybe it is getting confused by project.xml?
Comment 3 Jesse Glick 2009-01-31 19:49:46 UTC
Easily reproducible. Just create a project, Go to File, "project.properties", Enter.
Comment 4 Jesse Glick 2009-01-31 19:57:47 UTC
BTW

            files = new FileObject[listFileObjects.size()];
            int index = 0;
            for (FileObject file : listFileObjects) {
                files[index++] = file;
            }

can be simplified to

            files = listFileObjects.toArray(new FileObject[listFileObjects.size()]);
Comment 5 Jesse Glick 2009-01-31 20:00:42 UTC
Clearly the following code is wrong:

            for (FileObject file : parent.getChildren()) {
                fName = file.getName();
                if (fName.equals(baseName) && file.isValid()) {
                    listFileObjects.add(0,file);
                }

Should have:

if (!file.hasExt("properties")) {
  continue;

Even given that, getNthEntry should be written more conservatively and just quietly return null in case DataObject.find
returns some other kind of DataObject; I have in fact heard on the mailing lists of people writing specialized data
subtypes that match certain kinds of *.properties files.
}
Comment 6 Alexey Butenko 2009-02-01 09:33:49 UTC
Thanks for comments.

changeset 8f8221d23063
Comment 7 Jesse Glick 2009-02-01 16:22:46 UTC
Commenting out the DataObjectNotFoundException.printStackTrace() where you did would not prevent the ClassCastException
from being reported as an uncaught exception.
Comment 8 Alexey Butenko 2009-02-02 08:05:59 UTC
Yes, it is not prevent. But as you wrote the problem is that project.xml was taken into account.
And it is fixed. So only PropertiesDataObject instances can get there now.
Comment 9 Alexey Butenko 2009-02-02 08:13:18 UTC
Added DataObject instanceof PropertiesDataObject check 
changeset 9f4151676c90
Comment 10 Jesse Glick 2009-02-02 15:51:07 UTC
As I wrote earlier, it is possible (when using 3rd-party modules) for a *.properties file to not be a
PropertiesDataObject. 9f4151676c90 looks right.