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 217919 - URLMapper.findFileObject() returns FileObject with non-normalized File
Summary: URLMapper.findFileObject() returns FileObject with non-normalized File
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: REGRESSION
: 216685 216739 (view as bug list)
Depends on:
Blocks: 221039
  Show dependency tree
 
Reported: 2012-09-05 23:25 UTC by David Konecny
Modified: 2012-11-05 13:43 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 David Konecny 2012-09-05 23:25:01 UTC
This must be a recent regression as it used to work without problems until this week. I have a URL to a file, eg. file:/C:/Users/dkonecny/AppData/Local/MYNEWT~1/blank8448803923930322077.html and calling URLMapper.findFileObject() on such URL returns FileObject which File was not normalized. If you try to convert the FileObject back to File via FileUtil.toFile it will fail with

java.lang.AssertionError: Need to normalize C:\Users\dkonecny\AppData\Local\MYNEWT~1\blank8448803923930322077.html was C:\Users\dkonecny\AppData\Local\my new temp folder with long name\blank8448803923930322077.html
	at org.openide.filesystems.FileUtil.assertNormalized(FileUtil.java:141)
	at org.openide.filesystems.FileUtil.toFile(FileUtil.java:1016)

See issue 217914 for original report.
Comment 1 Jaroslav Tulach 2012-10-24 16:02:25 UTC
I am not sure this is a regression. A test to demonstrate that (passing on some version of NetBeans and failing on current version) would convince me it is.

> returns FileObject whichFile was not normalized.

How do you know? I suspect FileObjects and URLs know nothing about normalization, so I do not consider the argument valid.
Comment 2 David Konecny 2012-10-24 20:02:53 UTC
(In reply to comment #1)
> I am not sure this is a regression.

Even if it is not a regression it is a valid problem. Or it was when it was filed.

> A test to demonstrate that (passing on some
> version of NetBeans and failing on current version) would convince me it is.

Sure that would be nice but I do not have time for that - I narrowed down the problem to the concrete reproducible case.

> 
> > returns FileObject whichFile was not normalized.
> 
> How do you know?

I debugged this in Virtual Box running Windows 7 and saw it happening. 

> I suspect FileObjects and URLs know nothing about
> normalization, so I do not consider the argument valid.

Whatever you say, but simple calls like this should just work:

FileUtil.toFile(URLMapper.findFileObject(new URL("file:/C:/Users/dkonecny/AppData/Local/MYNEWT~1/blank8448803923930322077.html")))

but instead they throw:

java.lang.AssertionError: Need to normalize
C:\Users\dkonecny\AppData\Local\MYNEWT~1\blank8448803923930322077.html was
C:\Users\dkonecny\AppData\Local\my new temp folder with long
name\blank8448803923930322077.html
Comment 3 Jaroslav Tulach 2012-10-31 12:47:36 UTC
Changeset: d4b8cc653a1e
Author:    Jaroslav Tulach <jtulach@netbeans.org>
Date:      2012-10-31 13:43
Message:   #217919: normalize the File before returning it from toFile method
Comment 4 David Konecny 2012-11-01 00:40:11 UTC
Thanks.
Comment 5 Jaroslav Tulach 2012-11-01 09:39:12 UTC
*** Bug 216739 has been marked as a duplicate of this bug. ***
Comment 6 Quality Engineering 2012-11-02 03:27:46 UTC
Integrated into 'main-golden', will be available in build *201211020001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d4b8cc653a1e
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #217919: normalize the File before returning it from toFile method
Issue #217919 - URLMapper.findFileObject() returns FileObject with non-normalized File
Comment 7 Jaroslav Tulach 2012-11-05 13:43:42 UTC
*** Bug 216685 has been marked as a duplicate of this bug. ***