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 199471

Summary: FileUtil.normalizeFile may normalized into incorrect cases
Product: platform Reporter: Jan Lahoda <jlahoda>
Component: FilesystemsAssignee: Jaroslav Tulach <jtulach>
Status: RESOLVED FIXED    
Severity: normal CC: vv159170
Priority: P3    
Version: 7.1   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 183308    
Bug Blocks: 198565, 199551    

Description Jan Lahoda 2011-06-16 16:45:13 UTC
[recent build based on 8a5f80ebb3dd]

I would expect that this (junit) test case would pass (File=java.io.File, FileUtil=org.openide.filesystems.FileUtil,IOException=java.io.IOException):
-------------------------------------------------------------
public void testSomeMethod() throws IOException {
    File a = new File("C:\\a");
        
    a.delete();//so the test can be restarted
        
    assertTrue(a.createNewFile());
    File A = new File("C:\\A");
        
    assertEquals(a.getAbsolutePath(),FileUtil.normalizeFile(A).getAbsolutePath());
        
    assertTrue(A.delete());
        
    assertTrue(A.createNewFile());
        
    assertEquals(A.getAbsolutePath(),FileUtil.normalizeFile(A).getAbsolutePath());
}
-------------------------------------------------------------

But it does not. Note that in the end the file that exists on disk is C:\A, but normalize file returns C:\a in this case, because it remembers the result of the first normalizeFile. If the first normalizeFile would not be called, the result of the second normalize file would be C:\A, which is correct, IMO. This leads into quite unpredictable behavior. Introduced by bug #183308.

I would expect that the FileUtil.normalizeFile would:
-not change the input cases for non-existing files
-return the exact cases as are on disk for existing files
Comment 1 Quality Engineering 2011-06-18 15:09:36 UTC
Integrated into 'main-golden', will be available in build *201106180600* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ad241dfb5678
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #198565: file normalization after resolving relative file is probably not needed in BuildArtifactsMapperImpl, and causes problems due to #199471.
Comment 2 Jaroslav Tulach 2011-06-28 07:25:20 UTC
Possibly also causes bug 199551. Should we remove the caching?
Comment 3 Quality Engineering 2011-07-05 23:59:50 UTC
Integrated into 'releases'
Changeset: http://hg.netbeans.org/releases/rev/3775016f7d8a
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #198565: file normalization after resolving relative file is probably not needed in BuildArtifactsMapperImpl, and causes problems due to #199471.
Comment 4 Jaroslav Tulach 2011-07-14 15:28:22 UTC
ergonomics#43c8189679b6
Comment 5 Quality Engineering 2011-07-17 13:59:26 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/43c8189679b6
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #199471: FileUtil.normalizeFile may normalized into incorrect cases
Don't rely on cache when case of normalized file is changed