Skip to content

Commit

Permalink
fix: wait for service init event when intializing endpoint registry
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollovati committed Aug 25, 2024
1 parent 7afd961 commit c0661fc
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import jakarta.servlet.ServletContext;
import java.util.concurrent.CompletableFuture;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
Expand Down Expand Up @@ -64,8 +65,7 @@ EndpointNameChecker endpointNameChecker() {
/**
* Registers a default {@link EndpointAccessChecker} bean instance.
*
* @param accessAnnotationChecker
* the access controlks checker to use
* @param accessAnnotationChecker the access controlks checker to use
* @return the default Vaadin endpoint access checker bean
*/
@Produces
Expand All @@ -90,8 +90,7 @@ AccessAnnotationChecker accessAnnotationChecker() {
/**
* Registers a default {@link CsrfChecker} bean instance.
*
* @param servletContext
* the servlet context
* @param servletContext the servlet context
* @return the default bean
*/
@Produces
Expand Down Expand Up @@ -127,8 +126,7 @@ EndpointUtil endpointUtil() {
/**
* Registers the endpoint registry.
*
* @param endpointNameChecker
* the name checker to use
* @param endpointNameChecker the name checker to use
* @return the endpoint registry
*/
@Produces
Expand Down Expand Up @@ -229,13 +227,14 @@ RouteUnifyingServiceInitListener routeUnifyingServiceInitListener(

@Startup
void initializeEndpointRegistry() {
new EndpointRegistryInitializer(this.endpointController).serviceInit(vaadinServiceInitEvent);
EndpointRegistryInitializer registryInitializer = new EndpointRegistryInitializer(this.endpointController);
this.vaadinServiceInitEvent.thenAccept(registryInitializer::serviceInit);
this.vaadinServiceInitEvent = null;
}

private ServiceInitEvent vaadinServiceInitEvent;
private CompletableFuture<ServiceInitEvent> vaadinServiceInitEvent = new CompletableFuture<ServiceInitEvent>();

void onVaadinServiceInit(ServiceInitEvent event) {
this.vaadinServiceInitEvent = event;
this.vaadinServiceInitEvent.complete(event);
}
}

0 comments on commit c0661fc

Please sign in to comment.