We recently had the erroneous case in DeltaSpike that an Extension did call BeanManager#getBeans() in an @Observes ProcessBean method.
Doing so leads to random behaviour as the result of getBeans() depends on the order in which the other beans got processed already. E.g. getBeans(Object.class) will return an empty list for the first bean getting processed, and will return all beans -1 for the last bean. That just makes no sense and will create unreproducible bugs.
PROPOSAL:
We shall add spec language to BeanManager#getBeans() that any invocation before the AfterDeploymentValidation phase will result in a deployment error.
- relates to
-
CDI-315 Allow BeanManager methods, such as getBeans in AfterDeploymentValidation observers
- Closed
-
CDITCK-320 Test that certain BeanManager methods cannot be called during application init
- Resolved
-
WELD-1274 Check that certain BeanManager methods are not called at bootstrap
- Resolved
-
CDI-392 Clarify when the operations of BeanManager can be called
- Closed