United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4895132 : problems with filename cache on Windows

Details
Type:
Bug
Submit Date:
2003-07-23
Status:
Closed
Updated Date:
2003-10-06
Project Name:
JDK
Resolved Date:
2003-08-30
Component:
core-libs
OS:
solaris_8
Sub-Component:
java.io
CPU:
sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
1.4.2_02 (02)

Related Reports
Backport:
Relates:

Sub Tasks

Description
1. sun.io.useCanonPrefixCache cannot be disabled.

    private static boolean getBooleanProperty(String prop, boolean defaultVal) {
        String val = System.getProperty("sun.io.useCanonCaches");

  "sun.io.useCanonCaches" should be prop

2. For an existing file, getCanonicalPath() sometimes can produce
a pathname whose case doesn't match that of the existing file's pathname.
This doesn't matter in terms of being able to access the file, but it appears
that some applications, such as TomCat, depend on getting the correct case.
Sometimes the answer for the same input is inconsistent. Here's the
test program from the customer.

import java.io.*;

public class Test {

    public static void main(String args[]) {
        
        File test = null;
        test = new File("foo/Test.txt");
        try {
            System.out.println("Can path: " + test.getCanonicalPath())
;
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        test = new File("foo/test.Txt");
        try {
            System.out.println("Can path: " + test.getCanonicalPath())
;
        } catch (Exception e) {
            e.printStackTrace();
        }
        test = new File("foo/Test.Txt");
        try {
            System.out.println("Can path: " + test.getCanonicalPath())
;
        } catch (Exception e) {
            e.printStackTrace();
        }
        
    }

}

touch foo\test.txt
rm -f foo\Test.txt

On 1.4.2, this produces
c:\foo\test.txt
c:\foo\test.txt
c:\foo\Test.txt

With the cache disabled, it produces
c:\foo\test.txt
c:\foo\test.txt
c:\foo\test.txt

It is strange that #1 and #3 are different when the cache is enabled.

rm -f foo\test.txt
touch foo\Test.txt

1.4.2 with cache enabled produces:
c:\foo\Test.txt
c:\foo\test.txt
c:\foo\Test.txt

Cache disabled:
c:\foo\Test.txt
c:\foo\Test.txt
c:\foo\Test.txt

                                    

Comments
WORK AROUND

Specify -Dsun.io.useCanonCaches=false to the JVM.

###@###.### 2003-07-23
                                     
2003-07-23
EVALUATION

The first problem has been solved by the fix for 4846976. Looks like the second problem may have been introduced by the cache work in 1.4.2.
###@###.### 2003-07-23

The problem of canonicalization returning differently-capitalized file names
than on disk on the Windows platform is a side effect of the prefix cache that
was introduced in 1.4.2 for performance reasons (specifically startup time).
It seems clear that we can't completely avoid touching the disk, but we can
touch it only once per hit in the prefix cache instead of the multiple times a
full canonicalization requires. This has been implemented and fixes the problem.

###@###.### 2003-08-22
                                     
2003-08-22
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.2_02
tiger

FIXED IN:
1.4.2_02
tiger

INTEGRATED IN:
1.4.2_02
tiger
tiger-b18

VERIFIED IN:
1.4.2_02


                                     
2004-06-14



Hardware and Software, Engineered to Work Together