]
Matěj Novotný commented on WFLY-11601:
--------------------------------------
The approach I outlined above turns out to be wrong.
The {{WeldStartCompletionService}} itself relies on going last (after EE components and in
cleanup phase) in order to perform cleanup and optimization for Weld.
Trying to add that as a dependency of {{UndertowDeploymentService}} would then mean a
circular dependency or at least a delay in undertow service start which is too big (both
are bound to another phase anyway).
I am pretty sure we don't want to back off the optimization as that reduces the
runtime overhead and footprint of CDI-related components.
But ATM I just don't know how to solve this on service-bootstrap level.
The only thing that comes to mind is splitting the bootstrap even more - basically taking
{{WeldStartup#endInitialization()}} and creating two methods, one that does all the
remaining bootstrap work (building {{BeanIdentifierIndex}} plus processing
{{BeanDeploymentModules}}) and then other that does all the clean ups plus fires
initialized event. But that obviously breaks the code of all integrators (pretty much all
EE servers out there). Another nasty hack would be to just extract the remaining boot
logic into previous step (validation) and leave the end init to be purely cleaning up, but
that's not nice and can again break integrators code.
I'd like to hear what [~mkouba] has to say.
Weld vs Undertow bootstrap: Race condition
------------------------------------------
Key: WFLY-11601
URL:
https://issues.jboss.org/browse/WFLY-11601
Project: WildFly
Issue Type: Bug
Components: CDI / Weld, Web (Undertow)
Affects Versions: 15.0.1.Final
Reporter: Stefan Gr
Assignee: Matěj Novotný
Priority: Major
Attachments: TestApp.zip, TestLib.zip, changes.diff, deploy-failed.txt,
deploy-mixed-success.txt, deploy-success.txt, test-app-1.0.0.war,
weld-core-impl-3.0.5.Final.jar, weld-core-impl-3.0.5.Final.jar
WFLY-9732 / WFLY-10784 moves the completion of WELD from the WeldStartService to
WeldStartCompetionService. This causes a race condition with the UndertowDeploymentService
which executes the servlet listeners for context-initialized which again fires
ApplicationScope-initialized events in CDI.
You can find more in
[
WELD-2557|https://issues.jboss.org/browse/WELD-2557?focusedCommentId=1368...].
In short: WeldStartCompletionService and UndertowDeploymentService pushes the logic to
the executor service. It may happen, that the logik of undertow runs before the weld
completion. Events fired in the servlet listeners won't find all event observers.
A possible solution would bo to set the WeldStartCompletionService as a dependency of the
UndertowDeploymentService