-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Milestone
Description
Describe the bug
This is a follow-up of #6948 (comment)
When making the methods of an entity listener private (which by itself works, but maybe it shouldn't), it has the side effect that CDI beans are no longer injected.
Expected behavior
Not sure what would be the best expectation, but maybe one of the following:
- private entity listener methods are illegal, or cause an error/warning one way or another
- CDI injection still working for these private methode
How to Reproduce?
Have an entity listener that looks something like this:
@ApplicationScoped
public class MyEntityListener {
@Inject SomeCdiBean someCdiBean;
@PrePersist
private void prePersist(MyEntity entity) { // works for package-private, protected and public
if (someCdiBean == null) throw new AssertionError("should not be null");
}
}
And register it on some entity:
@Entity
@EntityListeners(MyEntityListener.class)
public class MyEntity {
// ...
}
Then trigger it, e.g. in a test:
@QuarkusTest
@Transactional
class MyEntityTest {
@Inject EntityManager entityManager;
@Test
void testEntityListener() {
entityManager.persist(new MyEntity());
}
}
Here's a full reproducer project with Quarkus 2.7.4: entitylistener-inject-entitymanager.zip