spring-cloud / spring-cloud/spring-cloud-gateway

Identical Routes are not considered equal: AsyncPredicate does not override equals()

Open
#3,236 6 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.