amaliujia commented on code in PR #10438:
URL: https://github.com/apache/ozone/pull/10438#discussion_r3388981077
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChunkBuffer.java:
##########
@@ -64,6 +67,22 @@ static ChunkBuffer wrap(List<ByteBuffer> buffers) {
return new ChunkBufferImplWithByteBufferList(buffers);
}
+ default void checkArgument(byte[] b, int offset, int length) {
+ Objects.requireNonNull(b, "b == null");
+ Preconditions.checkArgument(offset >= 0 && length >= 0,
+ "offset = %s, length = %s", offset, length);
+ Preconditions.checkArgument(length <= b.length - offset,
+ "length = %s out of range for array.length = %s, offset = %s",
+ length, b.length, offset);
+ if (length > remaining()) {
+ final BufferOverflowException boe = new BufferOverflowException();
+ boe.initCause(new IllegalArgumentException(
+ "Failed to put since length = " + length
+ + " > this.remaining() = " + remaining()));
+ throw boe;
+ }
Review Comment:
Can we share the same code here with
https://github.com/apache/ozone/blob/cecddd660080a80e269a0c4991e4f16f6232cc90/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChunkBufferImplWithByteBufferList.java#L140-L146
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]