Closed sbabcoc closed 1 month ago
@sbabcoc, thank you for creating this issue. We will troubleshoot it as soon as we can.
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-*
label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
This is kind of a duplicate of #13840
The spec only matches by name; hence, the hash only has the name.
The issue is not that the hash code checks just the name; the issue is that the equals
method also checks the value. Consequently, two cookies with the same name but different values will have the same hash code, but they will not be considered equal. We either need to add the value to the hash code computation, or remove it from equals
.
Is that the common pattern for what is added to the hash? It doesn't make intuitive sense to me that two objects get considered equal based on how the spec indexes it.
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.
What happened?
The contract for
equals
andhashCode
states that two objects considered to be equal should have the same hash code. In the current implementation,equals
compares both [name] and [value], buthashCode
is based only on [name]. This will result in bad behavior in collections where object hash code is significant (e.g. - HashMap, HashSet).How can we reproduce the issue?
Crack open Cookie.java and examine the implementations of
equals
andhashCode
:Relevant log output
There's no specific log output for this issue. The existing implementation will just produce unexpected results in contexts where object hash codes are significant.
Operating System
Immaterial
Selenium version
Java 4.21.0
What are the browser(s) and version(s) where you see this issue?
N/A
What are the browser driver(s) and version(s) where you see this issue?
N/A
Are you using Selenium Grid?
N/A