Skip to content

Apache Lucene open-source search software

throw a more helpful exception if supposed directory is a file

Daniel Naber129227dce17c
diff --git a/src/java/org/apache/lucene/store/FSDirectory.java b/src/java/org/apache/lucene/store/FSDirectory.java
index 6185f6c34be..b8535c35c36 100644
--- a/src/java/org/apache/lucene/store/FSDirectory.java
+++ b/src/java/org/apache/lucene/store/FSDirectory.java
@@ -181,6 +181,9 @@ public class FSDirectory extends Directory {
if (!directory.mkdirs())
throw new IOException("Cannot create directory: " + directory);
+ if (!directory.isDirectory())
+ throw new IOException(directory + " not a directory");
+
String[] files = directory.list(new LuceneFileFilter()); // clear old files
for (int i = 0; i < files.length; i++) {
File file = new File(directory, files[i]);