New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3707: javalib Inet6Address#hashCode is now more robust to null hostnames #3709
Fix #3707: javalib Inet6Address#hashCode is now more robust to null hostnames #3709
Conversation
…st to null hostnames
I believe this PR is ready for review. As per usual, I reviewed the logs of the failing tests. Those failures are the usual suspects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
@@ -45,7 +45,8 @@ final class Inet6Address private ( | |||
override def hashCode(): Int = { | |||
var res = 1 | |||
res = 31 * res + ju.Arrays.hashCode(ipAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ipaddress can be null too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you.
It is not evident to a reviewer and certainly not to me when I wrote it, but ju.Arrays.hashCode(null)
always returns 0. That is both robust sensible.
I added a comment to remind myself and others who try to verify that method in the future.
A runtime test would have been the alternative. I went with a comment to save a few cpu
cycles when run.
Dratted nulls!
I believe this PR is ready for review. As is my practice, I examined the log files of the tests which have completed as of the end |
Fix #3707:
javalib
Inet6Address#hashCode
is now more robust to null hostnames.