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 194326 - NullPointerException at org.netbeans.modules.search.MatchingObject.getName
Summary: NullPointerException at org.netbeans.modules.search.MatchingObject.getName
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P1 normal (vote)
Assignee: Yulia Novozhilova
URL:
Keywords:
Depends on: 194598
Blocks:
  Show dependency tree
 
Reported: 2011-01-13 21:38 UTC by Vladimir Kvashin
Modified: 2011-02-04 05:57 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 175833


Attachments
stacktrace (5.40 KB, text/plain)
2011-01-13 21:38 UTC, Vladimir Kvashin
Details
fix for review (24.74 KB, patch)
2011-02-02 11:47 UTC, Yulia Novozhilova
Details | Diff
fix for review (with -w option for diff) (19.82 KB, application/octet-stream)
2011-02-02 12:52 UTC, Yulia Novozhilova
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2011-01-13 21:38:11 UTC
Build: NetBeans IDE Dev (Build 110113-37061888d658)
VM: Java HotSpot(TM) Server VM, 11.3-b02, Java(TM) SE Runtime Environment, 1.6.0_13-b03
OS: SunOS

User Comments:
vkvashin: My project contains file objects that do not correspond to files.
This leads to NPEs. That's obviously incorrect.




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.search.MatchingObject.getName(MatchingObject.java:387)
   at org.netbeans.modules.search.NodeRenderer.getTreeCellRendererComponent(NodeRenderer.java:177)
   at javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimensions(BasicTreeUI.java:2717)
   at javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayoutCache.java:475)
   at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.updatePreferredSize(VariableHeightLayoutCache.java:1342)
   at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.getXOrigin(VariableHeightLayoutCache.java:1125)
Comment 1 Vladimir Kvashin 2011-01-13 21:38:15 UTC
Created attachment 104974 [details]
stacktrace
Comment 2 Vladimir Kvashin 2011-01-14 08:34:19 UTC
My project contains file objects that do not correspond to files.
This leads to NPEs, which is obviously incorrect.
Comment 3 Vladimir Kvashin 2011-01-14 08:40:33 UTC
The remedy is to switch to FileObject instead of file.
MatchingObject has only one constructor; it gets FileObject in it, so it isn't an issue. All usages of getFile can be replaced by use of FileObjects.

The only place file is needed is in NodeListener.java:632, where it is canonicalized. It can be converted to file in this place.
Comment 4 Vladimir Kvashin 2011-01-14 08:49:41 UTC
Steps to reproduce:
- activate C/C++ support,
- go to services pane > C/C++ development hosts, set up a host
- via context menu of the newly added host, add to Favorites some its directory
- select this directory in favorites, try searching something in it
If search finds some occurrences, tons of NPEs occur in UI thread,
this makes IDE not functional at all
Comment 5 Yulia Novozhilova 2011-01-21 18:54:51 UTC
Reproduced. While reproducing this issue I faced and filed another one: https://netbeans.org/bugzilla/show_bug.cgi?id=194598

Looks like "Add to Favorites" functionality wasn't tested enough (http://hg.netbeans.org/main/rev/c2ed5a6ca6e5).
Comment 6 Yulia Novozhilova 2011-02-02 11:47:54 UTC
Created attachment 105591 [details]
fix for review
Comment 7 Yulia Novozhilova 2011-02-02 12:28:15 UTC
Should be fixed now. http://hg.netbeans.org/core-main/rev/3a331f02b4f1
Excepting the problem that happens in case if remote system is Mac. The remote files have wrong modification date in this case and are treated as invalid for search. See #194598
Comment 8 Yulia Novozhilova 2011-02-02 12:52:54 UTC
Created attachment 105593 [details]
fix for review (with -w option for diff)

The fix is integrated but review and testing is very welcome.
Comment 9 Vladimir Kvashin 2011-02-02 12:58:14 UTC
I tried the fix, it seems to work ok.

I also had a brief glance at code changes and noticed one possible issue:
MatchingObject.java:385, method getName() returns getFileObject().getName()
while previously it returned File.getName(). 

Most likely it should return FileObject.getNameExt()


(I was also trapped into that many times while moving my code from files to
file objects...)
Comment 10 Yulia Novozhilova 2011-02-02 13:05:39 UTC
Thank you, Vladimir. Will fix.
Comment 11 Jiri Rechtacek 2011-02-02 15:42:56 UTC
The fix with Vladimir's recommendation makes sense, my test-case works for me. Thanks
Comment 12 Quality Engineering 2011-02-03 05:52:40 UTC
Integrated into 'main-golden', will be available in build *201102030000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/3a331f02b4f1
User: Yulia Novozhilova <ynov@netbeans.org>
Log: Fix #194326 -  NullPointerException at org.netbeans.modules.search.MatchingObject.getName
Comment 13 Quality Engineering 2011-02-04 05:57:32 UTC
Integrated into 'main-golden', will be available in build *201102040000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/db6424f6d366
User: Yulia Novozhilova <ynov@netbeans.org>
Log: Correct tests for BufferedCharSequence to test recent implementation changes(#194326)