lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Issues with lucene 4.10.0 on android
Date Fri, 26 Sep 2014 07:09:24 GMT
> 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 ( The NIO2 API allows
better error handling (see also 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 “”
> or simply an IOException. The suspect code exists in the “listCommits”
> method of “DirectoryReader.”
> try {
>, 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 is now
forbidden APIs and are no longer used in Lucene (see
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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message