Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8018849 | 7u45 | Alan Bateman | P3 | Closed | Fixed | b01 |
JDK-8016066 | 7u40 | Alan Bateman | P3 | Closed | Fixed | b30 |
Description
FULL PRODUCT VERSION :
java version " 1.7.0_17 "
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.2.9200]
A DESCRIPTION OF THE PROBLEM :
The Files.createDirectory(Path) method which forms part of NIO2 fails if the path passed to it is exactly 248 characters long. Shorter paths and longer paths both work fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.nio.file.FileSystemException: [...]: The filename or extension is too long.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Before;
import org.junit.Test;
public class TestProblem {
String path;
@Before
public void setupPath() throws Exception {
StringBuilder builder = new StringBuilder(new File(System.getProperty( " java.io.tmpdir " )).getAbsolutePath());
builder.append(File.separator);
while (builder.length() < 248) {
builder.append('0');
}
path = builder.toString();
File dir = new File(path);
if (dir.exists()) { // could use Files.deleteIfExists but assuming it probably has a similar bug
Files.delete(path.toPath());
}
}
@Test
public void testSpecificDirectory() throws Exception {
Path dir = new File(path).toPath();
Files.createDirectories(dir); // <-- FAILS HERE
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoiding using the API entirely seems to be the only safe workaround.
SUPPORT :
YES
java version " 1.7.0_17 "
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.2.9200]
A DESCRIPTION OF THE PROBLEM :
The Files.createDirectory(Path) method which forms part of NIO2 fails if the path passed to it is exactly 248 characters long. Shorter paths and longer paths both work fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.nio.file.FileSystemException: [...]: The filename or extension is too long.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Before;
import org.junit.Test;
public class TestProblem {
String path;
@Before
public void setupPath() throws Exception {
StringBuilder builder = new StringBuilder(new File(System.getProperty( " java.io.tmpdir " )).getAbsolutePath());
builder.append(File.separator);
while (builder.length() < 248) {
builder.append('0');
}
path = builder.toString();
File dir = new File(path);
if (dir.exists()) { // could use Files.deleteIfExists but assuming it probably has a similar bug
Files.delete(path.toPath());
}
}
@Test
public void testSpecificDirectory() throws Exception {
Path dir = new File(path).toPath();
Files.createDirectories(dir); // <-- FAILS HERE
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoiding using the API entirely seems to be the only safe workaround.
SUPPORT :
YES
Attachments
Issue Links
- backported by
-
JDK-8016066 (fs) Files.createDirectory fails if the resoved path is exactly 248 characters long
- Closed
-
JDK-8018849 (fs) Files.createDirectory fails if the resoved path is exactly 248 characters long
- Closed