Skip to content

Conversation

@jasonf20
Copy link
Contributor

This is a regression fix introduced in 1.12.1

What is the purpose of the change

Fix a regression in BinaryData.compareBytes introduced here: https://github.com/apache/avro/pull/3126/files

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Documentation

  • Does this pull request introduce a new feature? no

@github-actions github-actions bot added the Java Pull Requests for Java binding label Oct 27, 2025
@jasonf20
Copy link
Contributor Author

cc: @martin-g @belugabehr

@martin-g martin-g requested a review from Copilot October 27, 2025 16:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regression in the BinaryData.compareBytes method introduced in version 1.12.1, where bytes were incorrectly being treated as signed instead of unsigned during comparison.

  • Changed Arrays.compare to Arrays.compareUnsigned to ensure bytes are treated as unsigned values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martin-g
Copy link
Member

Let's add some tests!

@jasonf20 jasonf20 changed the title Fixed BinaryData.compareBytes to tread bytes as unsigned Fixed BinaryData.compareBytes to treat bytes as unsigned Oct 27, 2025
@jasonf20
Copy link
Contributor Author

Let's add some tests!

Sure, added

This is a regression fix introudeced in 1.12.1
added unit test
@jasonf20
Copy link
Contributor Author

I see that in the regression PR there are also usages of the method BinaryData.compareBytes that were replaced with direct calls to Arrays.compare. This PR doesn't address those, I don't know if comparing in those contexts needs to be unsigned or not, but the behaviour of those would have changed in the PR.

I noticed this issue since I use the BinaryData.compareBytes method directly. Do we need to revert the other changes as well?

@jasonf20
Copy link
Contributor Author

@martin-g I added a second commit that re-uses BinaryData.compareBytes again to restore the original behaviour. Without this I believe users would get different ordering of their data after upgrading to 1.12.1.

It's probably important to merge and release this quickly before adoption of 1.12.1 is widespread. That we we don't end up changing the ordering and then changing the ordering back again.

@martin-g martin-g requested a review from belugabehr October 28, 2025 10:51
This returns the comparision to be unsigned like it was in 1.12.0

This reverts commit 005ee80.
@jasonf20
Copy link
Contributor Author

jasonf20 commented Nov 6, 2025

Hi @belugabehr, any chance you can have a look at this?

@martin-g If @belugabehr isn't available can we move forward with merging. The change shouldn't be risky since it's simply reverting very recent changes.

@martin-g
Copy link
Member

martin-g commented Nov 6, 2025

I'd prefer someone from the Java team to approve it first.

@RyanSkraba
Copy link
Contributor

Hello, this looks like the right thing to do -- as a regression, it would be great to have a JIRA associated with it! I can create the JIRA, but if you'd like credit as reporter/fixer, let me know your JIRA id (and/or create one at https://selfserve.apache.org/jira-account.html)

@RyanSkraba RyanSkraba changed the title Fixed BinaryData.compareBytes to treat bytes as unsigned AVRO-4210: Fix BinaryData.compareBytes to treat bytes as unsigned Nov 23, 2025
Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified that this restores the behaviour of compareBytes from 1.12.0 and LGTM.

@RyanSkraba RyanSkraba merged commit 6a72c2b into apache:main Nov 23, 2025
9 checks passed
RyanSkraba pushed a commit to RyanSkraba/avro that referenced this pull request Nov 23, 2025
…ache#3537)

* Fixed BinaryData.compareBytes to treat bytes as unsigned

This is a regression fix introudeced in 1.12.1
added unit test

* Re-use the DirectBytes.compareBytes method to ensure consistency

This returns the comparision to be unsigned like it was in 1.12.0

This reverts commit 005ee80.
@RyanSkraba
Copy link
Contributor

Cherry-picked to branch-1.12.

@belugabehr
Copy link
Contributor

belugabehr commented Nov 24, 2025 via email

@RyanSkraba
Copy link
Contributor

I think the system is working well 😄 You made an improvement, somebody noticed a difference in behaviour and corrected it -- I'm grateful to both of you ❤️ and everybody wins!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants