Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084335 | emb-9 | Ivan Gerasimov | P4 | Resolved | Fixed | team |
JDK-8065482 | 8u45 | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
JDK-8064271 | 8u40 | Ivan Gerasimov | P4 | Resolved | Fixed | b15 |
JDK-8070033 | emb-8u47 | Ivan Gerasimov | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux XXX 3.0.0-21-generic #35-Ubuntu SMP Fri May 25 17:57:41 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
FileChannel.size() returns 0 for block devices on Linux. As a consequence, it is impossible to memory map a block device, because FileChannel.map() uses size() to determine whether the file is big enough, and in the case of a block device, since size() always returns 0, it always concludes that it isn't big enough, tries to enlarge it, and fails.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On Linux, compile the sample code and execute it using a command similar to this:
sudo java -cp . BlockDeviceBug /dev/sda
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should show something like this:
File: /dev/sda
Size: 500107862016
Actual size: 500107862016
ACTUAL -
It actually says:
File: /dev/sda
Size: 0
Actual size: 500107862016
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class BlockDeviceBug {
public static void main(String[] args) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(args[0], "r")) {
FileChannel channel = file.getChannel();
System.out.println("File: " + args[0]);
System.out.println("Size according to FileChannel: " + channel.size());
System.out.println("Actual size: " + file.length());
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround found.
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux XXX 3.0.0-21-generic #35-Ubuntu SMP Fri May 25 17:57:41 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
FileChannel.size() returns 0 for block devices on Linux. As a consequence, it is impossible to memory map a block device, because FileChannel.map() uses size() to determine whether the file is big enough, and in the case of a block device, since size() always returns 0, it always concludes that it isn't big enough, tries to enlarge it, and fails.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On Linux, compile the sample code and execute it using a command similar to this:
sudo java -cp . BlockDeviceBug /dev/sda
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should show something like this:
File: /dev/sda
Size: 500107862016
Actual size: 500107862016
ACTUAL -
It actually says:
File: /dev/sda
Size: 0
Actual size: 500107862016
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class BlockDeviceBug {
public static void main(String[] args) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(args[0], "r")) {
FileChannel channel = file.getChannel();
System.out.println("File: " + args[0]);
System.out.println("Size according to FileChannel: " + channel.size());
System.out.println("Actual size: " + file.length());
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround found.
- backported by
-
JDK-8064271 (fc) FileChannel.size() returns 0 for block devices on Linux
-
- Resolved
-
-
JDK-8065482 (fc) FileChannel.size() returns 0 for block devices on Linux
-
- Resolved
-
-
JDK-8070033 (fc) FileChannel.size() returns 0 for block devices on Linux
-
- Resolved
-
-
JDK-8084335 (fc) FileChannel.size() returns 0 for block devices on Linux
-
- Resolved
-
- relates to
-
JDK-8313674 (fc) java/nio/channels/FileChannel/BlockDeviceSize.java should test for more block devices
-
- Resolved
-