Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

test: list index files on failure

Michael McCandless426a5736d9e3
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
index 3316372e55a..19c10b52b0c 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -1166,6 +1166,7 @@ public class TestIndexWriter extends LuceneTestCase {
} catch (Throwable t) {
log.println("thread " + id + " FAILED; unexpected exception");
t.printStackTrace(log);
+ listIndexFiles(log, dir);
failed = true;
break;
}
@@ -1194,6 +1195,7 @@ public class TestIndexWriter extends LuceneTestCase {
failed = true;
log.println("thread " + id + ": CheckIndex FAILED: unexpected exception");
e.printStackTrace(log);
+ listIndexFiles(log, dir);
}
try {
IndexReader r = DirectoryReader.open(dir);
@@ -1203,6 +1205,7 @@ public class TestIndexWriter extends LuceneTestCase {
failed = true;
log.println("thread " + id + ": DirectoryReader.open FAILED: unexpected exception");
e.printStackTrace(log);
+ listIndexFiles(log, dir);
}
}
try {
@@ -1218,6 +1221,16 @@ public class TestIndexWriter extends LuceneTestCase {
throw new RuntimeException("thread " + id, e);
}
}
+
+ private void listIndexFiles(PrintStream log, Directory dir) {
+ try {
+ log.println("index files: " + Arrays.toString(dir.listAll()));
+ } catch (IOException ioe) {
+ // Suppress
+ log.println("failed to index files:");
+ ioe.printStackTrace(log);
+ }
+ }
}
public void testThreadInterruptDeadlock() throws Exception {
@@ -1730,7 +1743,6 @@ public class TestIndexWriter extends LuceneTestCase {
Arrays.fill(chars, 'x');
Document doc = new Document();
final String bigTerm = new String(chars);
- final BytesRef bigTermBytesRef = new BytesRef(bigTerm);
// This contents produces a too-long term:
String contents = "abc xyz x" + bigTerm + " another term";