lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 26196] - IndexWriter problem when create set to false
Date Thu, 04 Mar 2004 14:31:29 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26196>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26196

IndexWriter problem when create set to false

otis@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX



------- Additional Comments From otis@apache.org  2004-03-04 14:31 -------
Yes, the current behaviour is fine, it just needs to be documented in
IndexWriter's Javadocs.  I'd rather get an exception, than have Lucene create an
index in some weird place.
It is easy to check for existence of the directory before calling IndexWriter,
and 'mkdirs()-ing' it.

Stack trace, for the record:

Exception in thread "main" java.io.IOException: /tmp/wrong not a directory
        at org.apache.lucene.store.FSDirectory.<init>(FSDirectory.java:154)
        at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:132)
        at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:113)
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:151)
        at IWTest.main(IWTest.java:8)


You don't need and should not be catching the exception.  Instead, proactively
and explicitly check for the existence of the directory.  You could even inline
the check in the call to IndexWriter constructor:

.... = new IW(path, analyzer, !file.exists())

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


Mime
View raw message