wgtmac commented on code in PR #1031:
URL: https://github.com/apache/parquet-mr/pull/1031#discussion_r1109248942


##########
parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java:
##########
@@ -205,6 +206,12 @@ public void write(byte b[], int off, int len) {
       throw new IndexOutOfBoundsException(
           String.format("Given byte array of size %d, with requested 
length(%d) and offset(%d)", b.length, len, off));
     }
+    int targetBytesUsed = bytesUsed + len;

Review Comment:
   Thanks for the change!
   
   What about using `bytesUsed = Math.addExact(bytesUsed, len)`. It is 
available in java8 and looks more elegant to throw ArithmeticException by 
itself.
   
   
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#addExact(int,int)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to