lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Vysny (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENE-5855) BinaryDictionary may fail reading a file
Date Tue, 29 Jul 2014 15:27:39 GMT
Martin Vysny created LUCENE-5855:
------------------------------------

             Summary: BinaryDictionary may fail reading a file
                 Key: LUCENE-5855
                 URL: https://issues.apache.org/jira/browse/LUCENE-5855
             Project: Lucene - Core
          Issue Type: Bug
          Components: modules/analysis
    Affects Versions: 4.9
            Reporter: Martin Vysny


The following code may fail on other JVMs, e.g. on Android:

      final ByteBuffer tmpBuffer = ByteBuffer.allocateDirect(size);
      final ReadableByteChannel channel = Channels.newChannel(dictIS);
      final int read = channel.read(tmpBuffer);
      if (read != size) {
        throw new EOFException("Cannot read whole dictionary");
      }

The code expects that channel.read() will fill entire buffer contents, which is however not
the case: ReadableByteChannel.read() may even decide to read 0 bytes and this mimicks InputStream.read()
behavior. The current Lucene code accidentally works on Oracle Java because Oracle Java channel.read()
fills the buffer fully (just check the Channels.newChannel() implementation).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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


Mime
View raw message