yandrey321 commented on code in PR #10438:
URL: https://github.com/apache/ozone/pull/10438#discussion_r3389535438
##########
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:
I added for checkArgument(ByteBuffer) and removed duplicated code.
--
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]