Skip to content

Apache Lucene open-source search software

Fix WindowsFS test failure seen on Policeman Jenkins (#14706)

Uwe Schindler41abd7ad3169
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index eff4b71a20a..219b42fa4a2 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -142,9 +142,9 @@ Other
* GITHUB#14516: Move sloppySin into SloppyMath from GeoUtils (Ankit Jain)
-* GITHUB#14627, GITHUB#11920: Fix mock filesystem WindowsFS to also work on Windows.
- This is required to make tests pass on Windows 11 which no longer has
- all limitations of previous Windows versions. (Uwe Schindler)
+* GITHUB#14627, GITHUB#11920, GITHUB#14706: Fix mock filesystem WindowsFS to also
+ work on Windows. This is required to make tests pass on Windows 11 which no
+ longer has all limitations of previous Windows versions. (Uwe Schindler)
======================= Lucene 10.2.1 =======================
diff --git a/lucene/test-framework/src/test/org/apache/lucene/tests/mockfile/TestWindowsFS.java b/lucene/test-framework/src/test/org/apache/lucene/tests/mockfile/TestWindowsFS.java
index 48141b98e6f..8e6609fbe99 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/tests/mockfile/TestWindowsFS.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/tests/mockfile/TestWindowsFS.java
@@ -197,14 +197,16 @@ public class TestWindowsFS extends MockFileSystemTestCase {
if (r.nextBoolean()) {
// We need at least one char after the special char
// For example, in case of '/' we interpret `foo/` to just be a file `foo` which is valid
+ // We need at least 2 chars before the special character, because resolving a drive
+ // letter (C:) or a path starting with "/" will not fail on real Windows.
fileName =
- RandomStrings.randomAsciiLettersOfLength(r, r.nextInt(10))
+ RandomStrings.randomAsciiLettersOfLength(r, r.nextInt(2, 10))
+ reservedCharacters[r.nextInt(reservedCharacters.length)]
+ RandomStrings.randomAsciiLettersOfLength(r, r.nextInt(1, 10));
} else {
fileName = reservedNames[r.nextInt(reservedNames.length)];
}
- expectThrows(InvalidPathException.class, () -> dir.resolve(fileName));
+ expectThrows(InvalidPathException.class, fileName, () -> dir.resolve(fileName));
// some other basic tests
expectThrows(InvalidPathException.class, () -> dir.resolve("foo:bar"));