Skip to content

Fix byte comparisons for subsequences with nonzero offsets - #1141

Open
dajiaohuang wants to merge 1 commit into
apache:mainfrom
dajiaohuang:fix/2166-bytes-subsequence-compare
Open

dajiaohuang wants to merge 1 commit into
apache:mainfrom
dajiaohuang:fix/2166-bytes-subsequence-compare

Conversation

@dajiaohuang

Copy link
Copy Markdown

Bytes.compareToUnchecked() stops its comparison loop at minLen, even though its index starts at the backing-array offset. For nonzero-offset subsequences this compares too few bytes, potentially treating different values as equal and producing inconsistent ordering.

Include the offset in the loop end bound so all overlapping bytes are compared. Add regression coverage for ordering in both directions, equality, and byte-array comparisons with and without an offset.

Validation:

  • Original BytesTest: 22 tests, one regression failure. Fixed: all 22 pass.
  • Attempted mvn verify as requested by CONTRIBUTING.md. With task-local Java 21, API (89 tests), Accumulo (47 tests), and Core (20 tests) passed. The build stopped in Command: seven errors caused by InvalidPathException on resource paths beginning /D:/... on Windows. Mini/integration tests were not reached.
  • An earlier Java 26 attempt stopped at SpotBugs because it does not support class-file major version 70.
  • Formatting and git diff --check pass.

AI-assisted with OpenAI Codex (GPT-6.1-sol).

Generated-by: OpenAI Codex (GPT-6.1-sol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant