FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.7.0-nio2-b98)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux nick 3.0-ARCH #1 SMP PREEMPT Sat Aug 6 16:18:35 CEST 2011 x86_64 Intel(R) Core(TM)2 Duo CPU T9300 @ 2.50GHz GenuineIntel GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Key is that uname -r =>
3.0-ARCH
A DESCRIPTION OF THE PROBLEM :
The following lines of code (starting at line 46 in LinuxFileSystem.java) are wrong. The comment is actually wrong too, the real assumption is W.X.Y[-Z] format. The recent update of linux to 3.0 (removing the Y component of the version) breaks this code. Specifically my os.version is "3.0-ARCH" so vers[1] will be "0-ARCH" which won't parse as an int.
As a fix, the code should also strip off a trailing [-Z] if it's there before trying to parse as an int.
Code from LinuxFileSystem.java:
// assume X.Y[-Z] format
String osversion = AccessController
.doPrivileged(new GetPropertyAction("os.version"));
String[] vers = Util.split(osversion, '.');
assert vers.length >= 2;
int majorVersion = Integer.parseInt(vers[0]);
int minorVersion = Integer.parseInt(vers[1]); // THIS LINE FAILS
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create some code that calls java.io.File.createTempFile (say in FSBug.java)
2. javac FSBug.java
3. java FSBug
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should create a temp file and exit
ACTUAL -
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.nio.file.FileSystems.getDefault(FileSystems.java:176)
at java.io.File$TemporaryDirectory$1.run(File.java:1790)
at java.io.File$TemporaryDirectory$1.run(File.java:1787)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.File$TemporaryDirectory.isPosix(File.java:1786)
at java.io.File$TemporaryDirectory.<clinit>(File.java:1784)
at java.io.File.createTempFile(File.java:1879)
at java.io.File.createTempFile(File.java:1930)
at FSBug.main(FSBug.java:3)
Caused by: java.lang.NumberFormatException: For input string: "0-ARCH"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:484)
at java.lang.Integer.parseInt(Integer.java:519)
at sun.nio.fs.LinuxFileSystem.<init>(LinuxFileSystem.java:54)
at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:39)
at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:32)
at sun.nio.fs.UnixFileSystemProvider.<init>(UnixFileSystemProvider.java:52)
at sun.nio.fs.LinuxFileSystemProvider.<init>(LinuxFileSystemProvider.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at sun.nio.fs.DefaultFileSystemProvider$1.run(DefaultFileSystemProvider.java:52)
at sun.nio.fs.DefaultFileSystemProvider$1.run(DefaultFileSystemProvider.java:43)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.fs.DefaultFileSystemProvider.createProvider(DefaultFileSystemProvider.java:42)
at sun.nio.fs.DefaultFileSystemProvider.create(DefaultFileSystemProvider.java:70)
at java.nio.file.FileSystems$LazyInitialization.getDefaultProvider(FileSystems.java:108)
at java.nio.file.FileSystems$LazyInitialization.access$000(FileSystems.java:89)
at java.nio.file.FileSystems$LazyInitialization$1.run(FileSystems.java:98)
at java.nio.file.FileSystems$LazyInitialization$1.run(FileSystems.java:96)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.file.FileSystems$LazyInitialization.defaultFileSystem(FileSystems.java:95)
at java.nio.file.FileSystems$LazyInitialization.<clinit>(FileSystems.java:90)
... 9 more
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class FSBug {
public static void main(String[] args) throws Exception {
java.io.File.createTempFile("foo","bar");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
redefine os.version on the command line. So the above will work if you do:
java -Dos.version="3.0" FSBug
Java(TM) SE Runtime Environment (build 1.7.0-nio2-b98)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux nick 3.0-ARCH #1 SMP PREEMPT Sat Aug 6 16:18:35 CEST 2011 x86_64 Intel(R) Core(TM)2 Duo CPU T9300 @ 2.50GHz GenuineIntel GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Key is that uname -r =>
3.0-ARCH
A DESCRIPTION OF THE PROBLEM :
The following lines of code (starting at line 46 in LinuxFileSystem.java) are wrong. The comment is actually wrong too, the real assumption is W.X.Y[-Z] format. The recent update of linux to 3.0 (removing the Y component of the version) breaks this code. Specifically my os.version is "3.0-ARCH" so vers[1] will be "0-ARCH" which won't parse as an int.
As a fix, the code should also strip off a trailing [-Z] if it's there before trying to parse as an int.
Code from LinuxFileSystem.java:
// assume X.Y[-Z] format
String osversion = AccessController
.doPrivileged(new GetPropertyAction("os.version"));
String[] vers = Util.split(osversion, '.');
assert vers.length >= 2;
int majorVersion = Integer.parseInt(vers[0]);
int minorVersion = Integer.parseInt(vers[1]); // THIS LINE FAILS
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create some code that calls java.io.File.createTempFile (say in FSBug.java)
2. javac FSBug.java
3. java FSBug
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should create a temp file and exit
ACTUAL -
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.nio.file.FileSystems.getDefault(FileSystems.java:176)
at java.io.File$TemporaryDirectory$1.run(File.java:1790)
at java.io.File$TemporaryDirectory$1.run(File.java:1787)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.File$TemporaryDirectory.isPosix(File.java:1786)
at java.io.File$TemporaryDirectory.<clinit>(File.java:1784)
at java.io.File.createTempFile(File.java:1879)
at java.io.File.createTempFile(File.java:1930)
at FSBug.main(FSBug.java:3)
Caused by: java.lang.NumberFormatException: For input string: "0-ARCH"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:484)
at java.lang.Integer.parseInt(Integer.java:519)
at sun.nio.fs.LinuxFileSystem.<init>(LinuxFileSystem.java:54)
at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:39)
at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(LinuxFileSystemProvider.java:32)
at sun.nio.fs.UnixFileSystemProvider.<init>(UnixFileSystemProvider.java:52)
at sun.nio.fs.LinuxFileSystemProvider.<init>(LinuxFileSystemProvider.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at sun.nio.fs.DefaultFileSystemProvider$1.run(DefaultFileSystemProvider.java:52)
at sun.nio.fs.DefaultFileSystemProvider$1.run(DefaultFileSystemProvider.java:43)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.fs.DefaultFileSystemProvider.createProvider(DefaultFileSystemProvider.java:42)
at sun.nio.fs.DefaultFileSystemProvider.create(DefaultFileSystemProvider.java:70)
at java.nio.file.FileSystems$LazyInitialization.getDefaultProvider(FileSystems.java:108)
at java.nio.file.FileSystems$LazyInitialization.access$000(FileSystems.java:89)
at java.nio.file.FileSystems$LazyInitialization$1.run(FileSystems.java:98)
at java.nio.file.FileSystems$LazyInitialization$1.run(FileSystems.java:96)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.file.FileSystems$LazyInitialization.defaultFileSystem(FileSystems.java:95)
at java.nio.file.FileSystems$LazyInitialization.<clinit>(FileSystems.java:90)
... 9 more
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class FSBug {
public static void main(String[] args) throws Exception {
java.io.File.createTempFile("foo","bar");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
redefine os.version on the command line. So the above will work if you do:
java -Dos.version="3.0" FSBug
- duplicates
-
JDK-7028468 (fs) FileSystems.getDefault() fails when kernel micro version contains/ends non-numeric characters
-
- Closed
-