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 42965 - NPE from UserCommandSupport.setVariables - null from FileObject.getMIMEType()
Summary: NPE from UserCommandSupport.setVariables - null from FileObject.getMIMEType()
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 4.x
Hardware: PC Linux
: P1 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: REGRESSION
: 43365 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-09 18:50 UTC by Jesse Glick
Modified: 2008-12-22 17:57 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-05-09 18:50:02 UTC
Starting seeing this in my dev build as soon as I
open it. No idea how to reproduce. Anyway, UCS.sV
is simply doing

  vars.put("MIMETYPE", fo.getMIMEType());

which ought to be safe but apparently some
FileObject is returning null from getMIMEType().
This is forbidden according to FileObject Javadoc.
Probably a regression due to recent MIME handling
changes.
Comment 1 Jesse Glick 2004-05-09 19:04:18 UTC
I will put in a hotfix.
Comment 2 Jesse Glick 2004-05-09 20:58:44 UTC
Also found a possibly related problem that if you open a Java source
from a CVS filesystem, you get no syntax coloring. I fixed
VcsFileSystem to return null for mimeType and this seems to be
corrected. (AbstractFileSystem.Info.mimeType should return null unless
the FS has specific knowledge about the type of the file.) Not sure
exactly why this would have been recently broken but perhaps the
semantics of FileUtil.getMIMEType(FileObject) was changed.
Comment 3 Jesse Glick 2004-05-09 21:52:07 UTC
Please review patches and specifically semantics of FU.gMT(FO).

committed   * Up-To-Date  1.92       
openide/src/org/openide/filesystems/FileUtil.java
committed   * Up-To-Date  1.260      
vcscore/src/org/netbeans/modules/vcscore/VcsFileSystem.java
Comment 4 Jaroslav Tulach 2004-05-10 12:43:35 UTC
Jesse, maybe the behaviour is caused by my Friday changes in FU. I
tried to simulate the behaviour and reenabled one of my mimetype
tests, but they all seem to pass without problem. 

openide/test/unit/src/org/openide/filesystems/FileObjectTestHid.java,v
 <--  FileObjectTestHid.java
new revision: 1.33

Anyway thanks for fix and sorry for trouble.
Comment 5 Jaroslav Tulach 2004-05-10 15:43:25 UTC
I've got it. UCS.sV is calling getMIMEType() on folder. I thought that
this is supposed to return null, but apperently it used to return
something else (at least on VCS filesystems). After Jesse's fix it
returns content/unknown. Any opinion on what it should return? I can
write test to guarentee that (at least on filesystems we run tests on
- means everything except VCS).
Comment 6 Jesse Glick 2004-05-10 17:07:56 UTC
Well it's pretty stupid to actually call it on a folder, of course.
Nonetheless the Javadoc does say that it will never return null, and
that "content/unknown" is the fallback. Would be good if UCS.sV
stopped calling gMT for folders.
Comment 7 Jaroslav Tulach 2004-05-11 07:26:42 UTC
Added test to cover that:

openide/test/unit/src/org/openide/filesystems/FileObjectTestHid.java,v
 <--  FileObjectTestHid.java
new revision: 1.34
Comment 8 Martin Entlicher 2004-05-17 14:21:40 UTC
*** Issue 43365 has been marked as a duplicate of this issue. ***