Hi
 
> Background: My company has built an Android application that utilizes
> Lucene 4.7.0 to index and search upon a fairly static set of about 100,000
> documents. We have used numerous versions of Lucene over the years, and
> they have all worked well to accomplish this purpose.
> 
> Issue: Upon upgrading to Lucene 4.10.0, the application’s functionality broke.
> As it turns out, an exception named “java.nio.file.NoSuchFileException” is
> now utilized within the DirectoryReader class. This exception class is not
> available within the Android runtime, and the Dalvik VM crashes with an
> “unable to resolve exception” error every time a DirectoryReader tries to
> open.

Lucene 4.8+ changed from Java 6 to Java 7 as minimum requirement. With this 
move, we initially changed the NIOFSDirectory and MMapDirectory Directory 
implementations to use Java 7's NIO2 to open index files 
(https://issues.apache.org/jira/browse/LUCENE-4848). The NIO2 API allows better 
error handling (see also https://issues.apache.org/jira/browse/LUCENE-5945). 
This better error handling use a more fine-granular exception handling with 
more informative errors if something goes wrong. So you *have* to use the new 
Exception types, otherwise you would break error handling. In 4.8, 4.9 and 
4.10, Lucene's NIOFSDirectory and MMapDirectory implementations use NIO2 
internally, so the new Exception types like NoSuchFileException are needed here.

> Possible Solutions: This problem could be remedied by replacing the usage of
> “java.nio.file.NoSuchFileException” with “java.io.FileNotFoundException”
> or simply an IOException. The suspect code exists in the “listCommits”
> method of “DirectoryReader.”
> try {
>     sis.read(dir, fileName);
> } catch (NoSuchFileException | FileNotFoundException var10) {
>     sis = null;
> }
> 
> Is this something you would consider changing to make it compatible with
> android?

Sorry, no step backwards. Instead, we went one step further: In Lucene 5.0 - 
the version coming after 4.10.x - we did a complete cutover to NIO2, so all 
stuff around java.io.File is now forbidden APIs and are no longer used in 
Lucene (see https://issues.apache.org/jira/browse/LUCENE-5945). Everything in 
Lucene now uses java.nio.file.Path and java.nio.file.Files APIs (including 
virtual file systems).

Changing this Exception catch block to remove this exception would not help 
you, because you would get another error later, because NIO2 is missing on 
Android (as far as I know). Android is only partially Java 7 syntax compatible, 
but not API compatible at all - no APIs of Java 7 were implemented yet. They 
seem to be mostly compatible to Java 6, so you can only use Lucene 4.7.x with 
Android (no guarantees!!!)
 
> Thanks in Advance,
> 
> David

Uwe


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to