HyukjinKwon opened a new pull request, #56723:
URL: https://github.com/apache/spark/pull/56723

   ### What changes were proposed in this pull request?
   `UTF8String.getByte(int)` is documented as *"If byte index is invalid, 
returns 0"*, but the implementation performed an unchecked 
`Platform.getByte(base, offset + byteIndex)`, returning adjacent/uninitialized 
memory for out-of-range indices. This PR adds the bounds check so the method 
honors its documented contract:
   
   ```java
   public byte getByte(int byteIndex) {
     if (byteIndex < 0 || byteIndex >= numBytes) {
       return 0;
     }
     return Platform.getByte(base, offset + byteIndex);
   }
   ```
   
   ### Why are the changes needed?
   Under JDK 25 the out-of-bounds read returned non-zero adjacent memory, 
making `UTF8StringSuite.testGetByte` fail with `expected: <0> but was: <47>` in 
the **Maven (Scala 2.13, JDK 25)** scheduled build. The previous `0` was never 
guaranteed — it depended on memory layout. The fix makes the behavior 
deterministic across JDKs.
   
   ### Does this PR introduce any user-facing change?
   No.
   
   ### How was this patch tested?
   Existing `UTF8StringSuite` (including `testGetByte`).
   
   **Before (failing on master, JDK 25):** `UTF8StringSuite.testGetByte` — 
`expected: <0> but was: <47>`
   https://github.com/apache/spark/actions/runs/28035606804/job/82996960386
   
   **After (this fix, JDK 25):** `UTF8StringSuite` — *Tests: succeeded 34, 
failed 0*; `testGetByte` passes
   https://github.com/HyukjinKwon/spark/actions/runs/28065895861/job/83089981477
   
   This pull request and its description were written by Isaac.
   


-- 
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]

Reply via email to