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

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git


The following commit(s) were added to refs/heads/main by this push:
     new fbee54f8b fix(java): MemoryBuffer::readChars (#2438)
fbee54f8b is described below

commit fbee54f8b2fa2c9f5db124d555ce7235412dca73
Author: Leo <[email protected]>
AuthorDate: Sun Aug 10 21:57:50 2025 +0800

    fix(java): MemoryBuffer::readChars (#2438)
    
    ## What does this PR do?
    
    fix MemoryBuffer::readChars
    
    ## Related issues
    
    <!--
    Is there any related issue? Please attach here.
    
    - #xxxx0
    - #xxxx1
    - #xxxx2
    -->
    
    ## Does this PR introduce any user-facing change?
    
    
    - [ ] Does this PR introduce any public API change?
    - [ ] Does this PR introduce any binary protocol compatibility change?
    
    ## Benchmark
    
    ---------
    
    Co-authored-by: loushaokun <[email protected]>
---
 .../src/main/java/org/apache/fory/memory/MemoryBuffer.java          | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/java/fory-core/src/main/java/org/apache/fory/memory/MemoryBuffer.java 
b/java/fory-core/src/main/java/org/apache/fory/memory/MemoryBuffer.java
index ae35d1633..fe7704ca9 100644
--- a/java/fory-core/src/main/java/org/apache/fory/memory/MemoryBuffer.java
+++ b/java/fory-core/src/main/java/org/apache/fory/memory/MemoryBuffer.java
@@ -2362,7 +2362,7 @@ public final class MemoryBuffer {
     final char[] chars = new char[numBytes >> 1];
     // use subtract to avoid overflow
     if (readerIdx > size - numBytes) {
-      streamReader.readToUnsafe(chars, 0, numBytes);
+      streamReader.readToUnsafe(chars, Platform.CHAR_ARRAY_OFFSET, numBytes);
       return chars;
     }
     Platform.copyMemory(
@@ -2389,7 +2389,7 @@ public final class MemoryBuffer {
     final char[] arr = new char[numBytes >> 1];
     // use subtract to avoid overflow
     if (readerIdx > size - numBytes) {
-      streamReader.readToUnsafe(arr, 0, numBytes);
+      streamReader.readToUnsafe(arr, Platform.CHAR_ARRAY_OFFSET, numBytes);
       return arr;
     }
     Platform.UNSAFE.copyMemory(
@@ -2409,7 +2409,7 @@ public final class MemoryBuffer {
     final long[] longs = new long[numElements];
     // use subtract to avoid overflow
     if (readerIdx > size - numBytes) {
-      streamReader.readToUnsafe(longs, 0, numElements);
+      streamReader.readToUnsafe(longs, Platform.LONG_ARRAY_OFFSET, numBytes);
       return longs;
     }
     Platform.copyMemory(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to