Apache Solr open-source search software
LUCENE-7333: Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows
Uwe Schindlercc7cede7a58b
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex fb5d93aeb61..501f2eeb21b 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -147,6 +147,9 @@ Bug Fixesdateline and indexed non-point shapes are much bigger than the heatmap region.(David Smiley)+* LUCENE-7333: Fix test bug where randomSimpleString() generated a filename+ that is a reserved device name on Windows. (Uwe Schindler, Mike McCandless)+Other* LUCENE-7295: TermAutomatonQuery.hashCode calculates Automaton.toDot().hash,diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.javaindex 44c03ea4b7e..5ca8a8662af 100644--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java@@ -33,6 +33,7 @@ import java.util.Set;import java.util.zip.CRC32;import org.apache.lucene.index.DirectoryReader;+import org.apache.lucene.index.IndexFileNames;import org.apache.lucene.index.IndexNotFoundException;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.LuceneTestCase;@@ -1208,10 +1209,8 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {// Keep trying until virus checker refuses to delete:final String fileName;while (true) {- String candidate = TestUtil.randomSimpleString(random());- if (candidate.length() == 0) {- continue;- }+ // create a random filename (segment file name style), so it cannot hit windows problem with special filenames ("con", "com1",...):+ String candidate = IndexFileNames.segmentFileName(TestUtil.randomSimpleString(random(), 1, 6), TestUtil.randomSimpleString(random()), "test");try (IndexOutput out = dir.createOutput(candidate, IOContext.DEFAULT)) {out.getFilePointer(); // just fake access to prevent compiler warning}