This is an automated email from the ASF dual-hosted git repository.

keith-turner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 12925a2614 Use Java code to check bounds (#6661)
12925a2614 is described below

commit 12925a2614766ae199d65f378e90191735ee6041
Author: Keith Turner <[email protected]>
AuthorDate: Thu Nov 19 13:53:32 2026 -0500

    Use Java code to check bounds (#6661)
    
    Used standard java code to check bounds in SeekableByteArrayInputStream
---
 .../file/blockfile/impl/SeekableByteArrayInputStream.java | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
index 6821e7c8f4..b18935fa52 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
@@ -22,6 +22,7 @@ import static java.util.Objects.requireNonNull;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Objects;
 
 import javax.annotation.concurrent.NotThreadSafe;
 
@@ -47,13 +48,8 @@ public class SeekableByteArrayInputStream extends 
InputStream {
 
   @Override
   public int read(byte[] b, int offset, int length) {
-    if (b == null) {
-      throw new NullPointerException();
-    }
-
-    if (length < 0 || offset < 0 || length > b.length - offset) {
-      throw new IndexOutOfBoundsException();
-    }
+    requireNonNull(b);
+    Objects.checkFromIndexSize(offset, length, b.length);
 
     if (length == 0) {
       return 0;
@@ -112,13 +108,14 @@ public class SeekableByteArrayInputStream extends 
InputStream {
   public void close() throws IOException {}
 
   public SeekableByteArrayInputStream(byte[] buf) {
-    requireNonNull(buf, "bug argument was null");
+    requireNonNull(buf, "buf argument was null");
     this.buffer = buf;
     this.max = buf.length;
   }
 
   public SeekableByteArrayInputStream(byte[] buf, int maxOffset) {
-    requireNonNull(buf, "bug argument was null");
+    requireNonNull(buf, "buf argument was null");
+    Objects.checkFromIndexSize(0, maxOffset, buf.length);
     this.buffer = buf;
     this.max = maxOffset;
   }

Reply via email to