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

tabish121 pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git

commit 61812cc622f9d0239c70d4e6d999681a5ebcb002
Author: Arnaud Cogoluègnes <[email protected]>
AuthorDate: Wed Aug 5 11:05:45 2026 +0200

    PROTON-2947 Fix return value of cached hashCode calculation in Binary
    
    The hashCode() method was returning the local hc variable
    (which initialized to 0) on the first invocation, rather than the newly
    computed hash code. This caused inconsistent hash values across calls
    on the same instance, leading to Map lookup failures when iterating or
    copying maps across different JDK versions.
    
    (cherry picked from commit 26d64220f60cc538c5209a9fb4930c9a8ea17969)
---
 protonj2/src/main/java/org/apache/qpid/protonj2/types/Binary.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/types/Binary.java 
b/protonj2/src/main/java/org/apache/qpid/protonj2/types/Binary.java
index 0aac1340..f764c8fb 100644
--- a/protonj2/src/main/java/org/apache/qpid/protonj2/types/Binary.java
+++ b/protonj2/src/main/java/org/apache/qpid/protonj2/types/Binary.java
@@ -124,7 +124,8 @@ public final class Binary {
     public final int hashCode() {
         int hc = hashCode;
         if (hc == 0 && buffer != null) {
-            hashCode = buffer.hashCode();
+            hc = buffer.hashCode();
+            hashCode = hc;
         }
         return hc;
     }


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

Reply via email to