Hi
I use Lucene's test-framework and I did this:
File f = _TestUtil.createTempFile("test", "tmp", TEMP_DIR);
registerTempFile(f);
However, the test fails on NPE thrown from
_TestUtil.rmDirjava.lang.RuntimeException: java.lang.NullPointerException
at
org.apache.lucene.util.LuceneTestCase.afterClassLuceneTestCaseJ4(LuceneTestCase.java:311)
Caused by: java.lang.NullPointerException
at org.apache.lucene.util._TestUtil.rmDir(_TestUtil.java:73)
at
org.apache.lucene.util.LuceneTestCase.clearTempDirectoriesAfterClass(LuceneTestCase.java:359)
at
org.apache.lucene.util.LuceneTestCase.afterClassLuceneTestCaseJ4(LuceneTestCase.java:290)
... 15 more
The reason is that I registered a File that is a 'file' and not
'directory', so f.listAll returns null. The javadocs of registerTempFile()
don't say anything about file or directories, yet the test cleanup says
clearTempDirectories...
The question is what's wrong - the javadocs, or could we not make _rmDir
more robust by checking first f.isFile()?
Shai