Skip to content

Commit b4c66ea

Browse files
committed
use path as key instead of real path (it is enough)
1 parent 4af90f6 commit b4c66ea

File tree

1 file changed

+3
-5
lines changed
  • lucene/test-framework/src/java/org/apache/lucene/tests/mockfile

1 file changed

+3
-5
lines changed

lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.nio.file.attribute.BasicFileAttributes;
2525
import java.util.HashMap;
2626
import java.util.Map;
27+
import java.util.Optional;
2728

2829
/**
2930
* FileSystem that (imperfectly) acts like windows.
@@ -54,13 +55,10 @@ public WindowsFS(FileSystem delegate) {
5455

5556
/** Returns file "key" (e.g. inode) for the specified path */
5657
private Object getKey(Path existing) throws IOException {
57-
Object key = Files.readAttributes(existing, BasicFileAttributes.class).fileKey();
58-
if (key != null) {
59-
return key;
60-
}
6158
// the key may be null, e.g. on real Windows!
6259
// in that case we fallback to the real path
63-
return existing.toRealPath();
60+
return Optional.ofNullable(Files.readAttributes(existing, BasicFileAttributes.class).fileKey())
61+
.orElse(existing);
6462
}
6563

6664
@Override

0 commit comments

Comments
 (0)