You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Martin Vysny (JIRA)" <ji...@apache.org> on 2014/07/29 17:29:38 UTC
[jira] [Commented] (LUCENE-5855) BinaryDictionary may fail reading
a file
[ https://issues.apache.org/jira/browse/LUCENE-5855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14077826#comment-14077826 ]
Martin Vysny commented on LUCENE-5855:
--------------------------------------
The code is present in org.apache.lucene.analysis.ja.dict.BinaryDictionary:115
> 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