You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "wenbingshen (via GitHub)" <gi...@apache.org> on 2023/08/02 03:53:02 UTC

[GitHub] [bookkeeper] wenbingshen commented on a diff in pull request #4021: Fix negative position read on BufferedChannel cause data can't read problem.

wenbingshen commented on code in PR #4021:
URL: https://github.com/apache/bookkeeper/pull/4021#discussion_r1281358080


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java:
##########
@@ -243,6 +243,11 @@ public long forceWrite(boolean forceMetadata) throws IOException {
 
     @Override
     public synchronized int read(ByteBuf dest, long pos, int length) throws IOException {
+        // protect negative position read
+        if (pos < 0) {
+            throw new IllegalArgumentException("Negative position pos:" + pos);

Review Comment:
   `IllegalArgumentException` is an unchecked exception, can we use `IOException` and catch it in the program?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org