[ 
https://issues.apache.org/jira/browse/HDFS-7825?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sergey Shelukhin updated HDFS-7825:
-----------------------------------
    Summary: HdfsDataInputStream::read(ByteBuffer) method doesn't conform to 
its API  (was: read(ByteBuffer) method doesn't conform to its API)

> HdfsDataInputStream::read(ByteBuffer) method doesn't conform to its API
> -----------------------------------------------------------------------
>
>                 Key: HDFS-7825
>                 URL: https://issues.apache.org/jira/browse/HDFS-7825
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: Sergey Shelukhin
>
> ByteBufferReadable::read(ByteBuffer) javadoc says:
> {noformat}
> After a successful call, buf.position() and buf.limit() should be unchanged, 
> and therefore any data can be immediately read from buf. buf.mark() may be 
> cleared or updated. 
> {noformat}
> I have the following code: 
> {noformat}
>         ByteBuffer directBuf = ByteBuffer.allocateDirect(len);
>         int pos = directBuf.position();
>             int count = file.read(directBuf);
>             if (count < 0) throw new EOFException();
>             if (directBuf.position() != pos) {
>               RecordReaderImpl.LOG.info("Warning - position mismatch from " + 
> file.getClass()
>                   + ": after reading " + count + ", expected " + pos + " but 
> got " + directBuf.position());
>             }
> {noformat}
> and I get:
> {noformat}
> 15/02/23 15:30:56 [pool-4-thread-1] INFO orc.RecordReaderImpl : Warning - 
> position mismatch from class 
> org.apache.hadoop.hdfs.client.HdfsDataInputStream: after reading 6, expected 
> 0 but got 6
> {noformat}
> So the position is changed, unlike the API doc indicates.
> Also, while I haven't verified yet, it may be that the 0-length read is not 
> handled properly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to