8255576: (fs) Files.isHidden() throws ArrayIndexOutOfBoundsException (unix)
Reviewed-by: alanb
This commit is contained in:
parent
fe7672bac6
commit
f61ce32770
@ -352,7 +352,14 @@ public abstract class UnixFileSystemProvider
|
||||
UnixPath name = file.getFileName();
|
||||
if (name == null)
|
||||
return false;
|
||||
return (name.asByteArray()[0] == '.');
|
||||
|
||||
byte[] path;
|
||||
if (name.isEmpty()) { // corner case for empty paths
|
||||
path = name.getFileSystem().defaultDirectory();
|
||||
} else {
|
||||
path = name.asByteArray();
|
||||
}
|
||||
return path[0] == '.';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,7 +243,7 @@ class UnixPath implements Path {
|
||||
}
|
||||
|
||||
// returns {@code true} if this path is an empty path
|
||||
private boolean isEmpty() {
|
||||
boolean isEmpty() {
|
||||
return path.length == 0;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4313887 6838333 8005566 8032220 8215467
|
||||
* @bug 4313887 6838333 8005566 8032220 8215467 8255576
|
||||
* @summary Unit test for miscellenous methods in java.nio.file.Files
|
||||
* @library ..
|
||||
*/
|
||||
@ -87,6 +87,9 @@ public class Misc {
|
||||
* Tests isHidden
|
||||
*/
|
||||
static void testIsHidden(Path tmpdir) throws IOException {
|
||||
// passing an empty path must not throw any runtime exception
|
||||
assertTrue(!isHidden(Path.of("")));
|
||||
|
||||
assertTrue(!isHidden(tmpdir));
|
||||
|
||||
Path file = tmpdir.resolve(".foo");
|
||||
|
Loading…
Reference in New Issue
Block a user