[ 
https://issues.apache.org/jira/browse/HDFS-8885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14711935#comment-14711935
 ] 

Chris Nauroth commented on HDFS-8885:
-------------------------------------

Hello [~srevanka].  Thank you for posting the patch.  Here are a few notes.

# A {{ByteRangeInputStream}} starts out in {{SEEK}} status, which indicates the 
underlying HTTP stream needs to be opened.  If a caller calls {{available}} 
before any {{read}} calls, then the result won't be correct, because it has not 
yet determined the file length.  I recommend calling {{getInputStream}} first, 
which lazily opens the underlying HTTP stream if necessary.
# A similar situation occurs if a caller calls {{seek}} immediately before 
{{available}}.  Again, calling {{getInputStream}} first would handle this case 
correctly.
# It's typical for {{available}} to throw an {{IOException}} if called after 
the stream has been closed.  Once again, a call to {{getInputStream}} would 
cover this case, because that method is already implemented to throw an 
{{IOException}} if the stream is in {{CLOSED}} state.
# Can you please look into adding unit tests in {{TestByteRangeInputStream}}?


> ByteRangeInputStream used in webhdfs does not override available()
> ------------------------------------------------------------------
>
>                 Key: HDFS-8885
>                 URL: https://issues.apache.org/jira/browse/HDFS-8885
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: webhdfs
>    Affects Versions: 2.7.1
>            Reporter: Shradha Revankar
>            Assignee: Shradha Revankar
>            Priority: Minor
>         Attachments: HDFS-8885.000.patch, HDFS-8885.001.patch
>
>
> ByteRangeInputStream has to override the method {{available()}} , the super 
> class implementation returns 0. Clients using the method {{available()}} to 
> rely on available bytes information will end up with errors during reads if 
> WebhdfsFileSystem is used. 



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

Reply via email to