Skip to content

Commit 13eadde

Browse files
committed
8215372: test/jdk/java/nio/file/DirectoryStream/Basic.java not correct when using a glob
Backport-of: d1951aa
1 parent ff60b34 commit 13eadde

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/jdk/java/nio/file/DirectoryStream/Basic.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -73,22 +73,26 @@ static void doTest(final Path dir) throws IOException {
7373
private PathMatcher matcher =
7474
dir.getFileSystem().getPathMatcher("glob:f*");
7575
public boolean accept(Path file) {
76-
return matcher.matches(file);
76+
return matcher.matches(file.getFileName());
7777
}
7878
};
79+
80+
found = false;
7981
try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {
8082
for (Path entry: ds) {
81-
if (!entry.getFileName().equals(foo))
82-
throw new RuntimeException("entry not expected");
83+
if (entry.getFileName().equals(foo))
84+
found = true;
8385
}
86+
if (!found)
87+
throw new RuntimeException(String.format("Error: entry: %s was not found", foo));
8488
}
8589

8690
// check filtering: z* should not match any files
8791
filter = new DirectoryStream.Filter<Path>() {
8892
private PathMatcher matcher =
8993
dir.getFileSystem().getPathMatcher("glob:z*");
9094
public boolean accept(Path file) {
91-
return matcher.matches(file);
95+
return matcher.matches(file.getFileName());
9296
}
9397
};
9498
try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {

0 commit comments

Comments
 (0)