spring-cloud / spring-cloud/spring-cloud-gateway
Identical Routes are not considered equal: AsyncPredicate does not override equals()
Open
Nobody has claimed this yet.
bug
help wanted
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Two logically equal Routes are not programmatically equal since Route's equals() compares predicates, and the AsyncPredicate class does not override equals() (hence you get a simple reference comparison). Here's a test that reproduces the issue:
class RouteEqualityTest {
@Test
void testTwoIdenticalRouteAreEqual() {
assertThat(getRouteBuilderStub().build()).isEqualTo(getRouteBuilderStub().build());
}
private Route.AsyncBuilder getRouteBuilderStub() {
return Route.async()
.id("123")
.uri("https://example.com")
.predicate(exchange -> exchange.getRequest()
.getPath()
.value()
.equals("/test-path"));
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read Route.equals and AsyncPredicate first, then run the supplied RouteEqualityTest reproduction using Route.async(). Done means independently built routes with identical configuration compare equal, with regression coverage for predicate comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100