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

ASF GitHub Bot commented on HDFS-15042:
---------------------------------------

virajjasani commented on code in PR #1747:
URL: https://github.com/apache/hadoop/pull/1747#discussion_r940734766


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferPositionedReadable.java:
##########
@@ -54,12 +69,11 @@ public interface ByteBufferPositionedReadable {
    * stream supports this interface, otherwise they might get a
    * {@link UnsupportedOperationException}.
    * <p>
-   * Implementations should treat 0-length requests as legitimate, and must not
+   * Implementations MUST treat 0-length requests as legitimate, and MUST NOT
    * signal an error upon their receipt.
-   * <p>
-   * This does not change the current offset of a file, and is thread-safe.
-   *
-   * @param position position within file
+   * The {@code position} offset MUST BE zero or positive; if negative
+   * an EOFException SHALL BE raised.

Review Comment:
   If `position` is negative, this method seems to be returning `-1` instead of 
throwing EOF with `NEGATIVE_POSITION_READ` reason. EOF with 
`NEGATIVE_POSITION_READ` is being thrown with this patch only with `void 
readFully(long position, ByteBuffer buf)` method.
   
   
   DFSInputStream:
   ```
     private int pread(long position, ByteBuffer buffer)
         throws IOException {
       // sanity checks
       dfsClient.checkOpen();
       if (closed.get()) {
         throw new IOException("Stream closed");
       }
       failures = 0;
       long filelen = getFileLength();
       if ((position < 0) || (position >= filelen)) {
         return -1;
       }
   
   ```



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferPositionedReadable.java:
##########
@@ -25,9 +25,24 @@
 import org.apache.hadoop.classification.InterfaceStability;
 
 /**
+ * The javadocs for this interface follows RFC 2119 rules regarding the use of
+ * MUST, MUST NOT, MAY, and SHALL.
+ * <p>
  * Implementers of this interface provide a positioned read API that writes to 
a
  * {@link ByteBuffer} rather than a {@code byte[]}.
- *
+ * <p>
+ * <b>Thread safety</b>
+ * <p>
+ * These operations doe not change the current offset of a stream as returned

Review Comment:
   nit: s/doe/does





> Add more tests for ByteBufferPositionedReadable 
> ------------------------------------------------
>
>                 Key: HDFS-15042
>                 URL: https://issues.apache.org/jira/browse/HDFS-15042
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: fs, test
>    Affects Versions: 3.3.0
>            Reporter: Steve Loughran
>            Assignee: Steve Loughran
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> There's a few corner cases of ByteBufferPositionedReadable which need to be 
> tested, mainly illegal read positions. Add them



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to