lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Goddard <michael.j.godd...@saic.com>
Subject NullPointerException: FSDirectory.create(FSDirectory.java:174)
Date Fri, 05 Aug 2005 21:04:35 GMT
Hello,

Today, while using Lucene 1.9-rc1-dev, I encountered this exception:

java.lang.NullPointerException
  at org.apache.lucene.store.FSDirectory.create(FSDirectory.java:174)
  at org.apache.lucene.store.FSDirectory.init(FSDirectory.java:150)
  at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:122)
  at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:225)

Puzzled, I added some debugging println() statements in FSDirectory and 
found out that java.io.tmpdir did not exist in my setup.  It may be that 
I am in a unique situation, having accidentally changed that value to 
some non-existent directory.  If I'm not, someone else might encounter 
the same problem.  Just in case, below is the little patch I generated 
from the change I came up with.

    Mike

Index: org/apache/lucene/store/FSDirectory.java
===================================================================
--- org/apache/lucene/store/FSDirectory.java    (revision 230511)
+++ org/apache/lucene/store/FSDirectory.java    (working copy)
@@ -146,6 +146,13 @@
     else {
       lockDir = new File(LOCK_DIR);
     }
+    // Ensure that lockDir exists and is a directory.
+    if (!lockDir.exists()) {
+      if (!lockDir.mkdirs())
+        throw new IOException("Cannot create directory: " + lockDir);
+    } else if (!lockDir.isDirectory()) {
+      throw new IOException("Found regular file where directory 
expected: " + lockDir);
+    }
     if (create) {
       create();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message