Added comment to the reasoning behind the hashCode() logic implemented in the COPSHan... 62/19462/2
authorSteven Pisarski <s.pisarski@cablelabs.com>
Fri, 1 May 2015 22:17:04 +0000 (16:17 -0600)
committerThomas Kee <xsited@yahoo.com>
Fri, 8 May 2015 19:52:00 +0000 (12:52 -0700)
Change-Id: Idab26a59bc344c93040bea988a98e033873193f4
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-driver/src/main/java/org/umu/cops/stack/COPSHandle.java

index 9d91d76286801d8f58b27b8522ba697c67d68f25..06c03582ee481ce47666448a0a3e7cd885b6f891 100644 (file)
@@ -132,7 +132,15 @@ public class COPSHandle extends COPSObjBase {
     @Override
     public int hashCode() {
         int result = super.hashCode();
-        List<Byte> allBytes = new ArrayList<>();
+
+        /*
+         Retrieve hash for the bytes contained in both COPSData members as equivalent objects may contain 0 value bytes
+         either trailing in the _data member or contained in the _padding. This generally will occur between an object
+         constructed via a public constructor vs. parsed from a byte[].
+
+         This is important as this object is known to be used as a key to Maps.
+          */
+        final List<Byte> allBytes = new ArrayList<>();
         for (final byte val : _data.getData()) {
             allBytes.add(val);
         }