But I did not find where to upload this patch file in JIRA bug report.
Can someone help me?
On 5/17/06, Chris Hostetter <[EMAIL PROTECTED]> wrote:
: I put Lock in IndexReader.indexExists function, and testes for a few days
: It worked fine. I never had that mistery problem.
:
: How can put the patch in a JIRA issue?
Please take a look at the recently added FAQ "How do I contribute an
improvement?"...
http://wiki.apache.org/jakarta-lucene/LuceneFAQ#head-f965d6439ac8fad1f0fe9cfe2d2dbfa0af2649cd
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: src/java/org/apache/lucene/index/IndexReader.java =================================================================== --- src/java/org/apache/lucene/index/IndexReader.java (revision 409403) +++ src/java/org/apache/lucene/index/IndexReader.java (working copy) @@ -318,7 +318,8 @@ * @return <code>true</code> if an index exists; <code>false</code> otherwise */ public static boolean indexExists(String directory) { - return (new File(directory, IndexFileNames.SEGMENTS)).exists(); + File file = new File(directory); + return IndexReader.indexExists(file); } /** @@ -328,7 +329,30 @@ * @return <code>true</code> if an index exists; <code>false</code> otherwise */ public static boolean indexExists(File directory) { - return (new File(directory, IndexFileNames.SEGMENTS)).exists(); + try{ + if(directory.exists()){ + final Directory dir = FSDirectory.getDirectory(directory, false); + final File dirFile = directory; + + while(dir.makeLock(IndexWriter.COMMIT_LOCK_NAME).isLocked()){ + try{ + Thread.sleep(50); + }catch(InterrupptedException e){} + } + Boolean ret = (Boolean) + new Lock.With(dir.makeLock(IndexWriter.COMMIT_LOCK_NAME), + IndexWriter.COMMIT_LOCK_TIMEOUT){ + public Object doBody() throws IOException { + return new Boolean(new File(dirFile, IndexFileNames.SEGMENTS).exists()); + } + }.run(); + return ret.booleanValue(); + }else{ + return false; + } + }catch(IOException e){ + return false; + } } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]