SerialBlob has an inconsistency between equals() and hashCode()

Mitsuru Kariya mitsuru.kariya at oss.nttdata.com
Tue May 11 13:53:23 UTC 2021


Hi,

Please see the sample code below.

SerialBlob sb1 = new SerialBlob(new byte[]{1, 2, 3});
SerialBlob sb2 = new SerialBlob(new byte[]{1, 2, 3, 4, 5});
sb2.truncate(3);
System.out.println(sb1.equals(sb2));
System.out.println(sb1.hashCode() == sb2.hashCode());

I think that it should output "true" & "true" but the current 
implementation outputs "true" & "false".

I know the use of SerialBlob.hashCode() is uncommon, but I think it is 
better to be fixed.
If it's worth changing, could anyone submit this issue to JBS for me?
I'm ready to submit a pull request, but I don't have an Author role.

Please let me know if there is a better place to do so.

Thanks


More information about the core-libs-dev mailing list