RequestPattern breaks hashCode contract
See original GitHub issueRequestPattern breaks java hashCode contract with respect to equals.
If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
A = {
"urlPath" : "/test",
"method" : "GET"
}
B = {
"urlPath" : "/test",
"method" : "GET"
}
A equals B = true
B equals A = true
A.hashCode equals B.hashCode = false
this is because hashCode includes matcher, defaultMatcher
whereas equals does not
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Java equals() and hashCode() Contracts - Baeldung
In this tutorial, we'll introduce two methods that closely belong together: equals() and hashCode(). We'll focus on their relationship with ...
Read more >Hashcode and equals methods contract - java - Stack Overflow
In case of not using a hash based collection, you can break the contract and need not to override the hashcode method -...
Read more >What will happen when hashcode() and equals() contract will ...
When equals is broken, two objects that hold the same data cannot be tested for equality Real life: you log in to a...
Read more >How (not) to break your app with hashCode() and equals()
The basic rule of the contract states that if two objects are equal to each other based on equals() method, then the hash...
Read more >Overriding equals() and hashCode() method in Java and ...
1) If two objects are equal by equals() method then there hashcode must be same. 2) If two objects are not equal by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah, shame it’s Java 8 upwards. WireMock needs to stay on 7 for a while longer unfortunately.
So looking forward to java 8 😉
BTW If you are still interested in
pojo-tester
features (more stable pojo-methods, avoid boilerplate tests), before completly switching to java 8, and using intellij you can switch to java8 only test module in Project Structure 😉