pchintar opened a new pull request, #22310:
URL: https://github.com/apache/kafka/pull/22310

   prefixScan currently behaves inconsistently across state store 
implementations when the prefix has no lexicographically larger upper bound.
   
   For example, given the following keys:
   
   - FF
   - FF 00
   - FF 10
   - FE
   
   Calling `prefixScan(FF)` should return:
   
   - FF
   - FF 00
   - FF 10
   
   `RocksDBStore` already handles this case correctly by treating the upper 
bound as unbounded when incrementing the prefix overflows.
   
   However, `InMemoryKeyValueStore`, `MemoryNavigableLRUCache`, and 
`CachingKeyValueStore` directly call `ByteUtils.increment(...)`, which throws 
`IndexOutOfBoundsException` for prefixes such as `0xFF`.
   
   This causes `prefixScan` to fail before iteration begins for in-memory state 
store implementations.
   
   This PR centralizes overflow-safe increment handling in 
`ByteUtils.incrementWithoutOverflow(...)` and updates the affected state stores 
to use the shared implementation when handling prefixes without an upper bound.
   
   A regression test has been added reproducing the failure with prefix `0xFF`.
   
   ### Testing
   
   ```bash
   ./gradlew spotlessApply
   ./gradlew :streams:test --tests 
org.apache.kafka.streams.state.internals.InMemoryKeyValueStoreTest.shouldPrefixScanPrefixWithNoUpperBound
   ./gradlew :streams:checkstyleMain :streams:checkstyleTest 
:clients:checkstyleMain


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

Reply via email to