question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequestPattern breaks hashCode contract

See original GitHub issue

RequestPattern 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:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
tomakehurstcommented, Oct 3, 2016

Ah, shame it’s Java 8 upwards. WireMock needs to stay on 7 for a while longer unfortunately.

0reactions
sta-szekcommented, Oct 3, 2016

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 😉

image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found