Skip to content

Conversation

JoeCqupt
Copy link
Contributor

@JoeCqupt JoeCqupt commented Aug 28, 2025

#3896

Route with the same order/priority may be change relative order when the RefreshRoutesEvent trigger to update Scoped route.

reproduce code:

	@Test
	public void updateScopedRoutes() {
		Map<String, Object> metadata = Map.of("metadata-key1", "metadata-value1");
		int order = 0;
		Route route1 = route(1, order, Collections.EMPTY_MAP);
		Route route2 = route(2, order, metadata);
		CachingRouteLocator locator = new CachingRouteLocator(() -> Flux.just(route1, route2));

		List<Route> routes = locator.getRoutes().collectList().block();
		assertThat(routes).containsExactly(route1, route2);

		RefreshRoutesEvent event = new RefreshRoutesEvent(this, metadata);
		locator.onApplicationEvent(event);
		routes = locator.getRoutes().collectList().block();
		assertThat(routes).containsExactly(route1, route2);
	}

	Route route(int id, int order, Map<String, Object> metadata) {
		return Route.async()
			.id(String.valueOf(id))
			.uri("http://localhost/" + id)
			.order(order)
			.predicate(exchange -> true)
			.metadata(metadata)
			.build();
	}

Signed-off-by: joecqupt <joe469391363@gmail.com>
@spencergibb
Copy link
Member

Can you add a test that fails without your fix and succeeds with it?

Signed-off-by: joecqupt <joe469391363@gmail.com>
Signed-off-by: joecqupt <joe469391363@gmail.com>
@JoeCqupt
Copy link
Contributor Author

JoeCqupt commented Aug 29, 2025

@spencergibb @ryanjbaxter PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants