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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new f477c3166 [test] Fix random test in ByteArraySeekableStreamTest. 
(#3118)
f477c3166 is described below

commit f477c31664ac14c2c3e8dbd666f4b247fee370af
Author: YeJunHao <[email protected]>
AuthorDate: Fri Mar 29 16:27:00 2024 +0800

    [test] Fix random test in ByteArraySeekableStreamTest. (#3118)
---
 .../java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/paimon-common/src/test/java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java
 
b/paimon-common/src/test/java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java
index e725e2a3d..2df02e85d 100644
--- 
a/paimon-common/src/test/java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java
+++ 
b/paimon-common/src/test/java/org/apache/paimon/fs/ByteArraySeekableStreamTest.java
@@ -40,7 +40,7 @@ public class ByteArraySeekableStreamTest {
         
Assertions.assertThat(byteArraySeekableStream.available()).isEqualTo(b.length);
 
         for (int i = 0; i < RANDOM.nextInt(1000); i++) {
-            int position = RANDOM.nextInt(bl);
+            int position = RANDOM.nextInt(bl - 1);
             int length = RANDOM.nextInt(b.length - position - 1);
             byte[] expected = new byte[length];
             System.arraycopy(b, position, expected, 0, length);
@@ -55,7 +55,11 @@ public class ByteArraySeekableStreamTest {
             int position = RANDOM.nextInt(bl);
             byteArraySeekableStream.seek(position);
             for (int j = 0; j < 100; j++) {
-                Assertions.assertThat(b[position + j])
+                int testPosition = position + j;
+                if (testPosition >= b.length) {
+                    break;
+                }
+                Assertions.assertThat(b[testPosition])
                         .isEqualTo((byte) byteArraySeekableStream.read());
             }
         }

Reply via email to