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 250472 - FileObj.getFileObject(String name, String ext) should throw UnsupportedOperationException
Summary: FileObj.getFileObject(String name, String ext) should throw UnsupportedOperat...
Status: RESOLVED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-17 19:06 UTC by dragor
Modified: 2015-10-22 15:37 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dragor 2015-02-17 19:06:47 UTC
I think FileObject method which are only supported by FolderObj, should throw  UnsupportedOperationException.

For examples:
FileObject createFolder(final String name) 
FileObject createData(final String name, final String ext)
FileObject getFileObject(final String name, final String ext)

getFileObject does not throw any exception just return null.

The FileObject api would be more user friendly with this improvement.
Comment 1 Jaroslav Havlin 2015-02-20 12:55:41 UTC
I see, implementation FileObj.getFileObject(String, String) in module masterfs returns null, although it should throw IllegalArgumentException - JavaDoc says so.

But some modules may depend on this incorrect behavior, so fixing this may break them. I'll need to evaluate possible impact of the fix.

Thank you for reporting.
Comment 2 dragor 2015-02-20 18:41:18 UTC
(In reply to Jaroslav Havlin from comment #1)
> I see, implementation FileObj.getFileObject(String, String) in module
> masterfs returns null, although it should throw IllegalArgumentException -
> JavaDoc says so.
> 
> But some modules may depend on this incorrect behavior, so fixing this may
> break them. I'll need to evaluate possible impact of the fix.
> 
> Thank you for reporting.

Thanks for your response.
Comment 3 Jaroslav Havlin 2015-10-22 15:37:05 UTC
> some modules may depend on this incorrect behavior
Some implementations of FileObject support relative paths, so getFileObject() on regular file becomes valid.
For example (copied from one of our test cases):
fo1.getFileObject("../../x/y.java")

Throwing exception from FileObj.getFileObject() would break some modules, so we should stay with the current behavior.

Thank you very much for reporting. Your point is correct, but the fix would break backward compatibility.