Skip to content

Commit

Permalink
test: Fix duplicate registration (#9233)
Browse files Browse the repository at this point in the history
Lock the registry when registering
dynamic route in serviceInit to not have
a race where 2 inits note that path is not
registered and then try to register the route.

Fixes #9223
  • Loading branch information
caalador committed Oct 26, 2020
1 parent d45b433 commit 5cfbe00
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public void serviceInit(ServiceInitEvent event) {

RouteConfiguration configuration = RouteConfiguration
.forApplicationScope();
if (!configuration
.isPathAvailable(DYNAMICALLY_REGISTERED_ROUTE)) {
configuration.setRoute(DYNAMICALLY_REGISTERED_ROUTE,
// lock registry from any other updates to get registrations correctly.
configuration.getHandledRegistry().update(() -> {
if (!configuration.isPathRegistered(DYNAMICALLY_REGISTERED_ROUTE)) {
configuration.setRoute(DYNAMICALLY_REGISTERED_ROUTE,
DynamicallyRegisteredRoute.class);
}
}
});

event.addRequestHandler((session, request, response) -> {
requestCount.incrementAndGet();
Expand Down

0 comments on commit 5cfbe00

Please sign in to comment.