Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait for service init event when intializing endpoint registry #888

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading