CDI events qualifiers not working when abstract superclass is in a library
See original GitHub issueDescribe the bug
CDI events qualifiers are not working well when abstract superclass is in a library since when implementing the class it will be registered as a general observer instead of one with a qualifier. Check https://github.com/MarcoMartins86/event_qualifier_issue for more details.
Expected behavior
If I trigger an important event http://localhost:8080/Events/Important
should appear:
Library AbstractObserverImportantEvent: Important event message 0 Event qualifiers[[@org.acme.ImportantEvent(), @javax.enterprise.inject.Any()]]
Runner ImportantEventImpl: Important event message 0
Actual behavior
If I trigger an important event http://localhost:8080/Events/Important
appears:
Library AbstractObserverNormalEvent: Important event message 0 Event qualifiers[[@org.acme.ImportantEvent(), @javax.enterprise.inject.Any()]]
Runner NormalEventImpl: Important event message 0
Library AbstractObserverImportantEvent: Important event message 0 Event qualifiers[[@org.acme.ImportantEvent(), @javax.enterprise.inject.Any()]]
Runner ImportantEventImpl: Important event message 0
To Reproduce
A project that reproduces this https://github.com/MarcoMartins86/event_qualifier_issue
Steps to reproduce the behavior:
- make
- Do GET to http://localhost:8080/Events/Important
- Check the command line for the prints
Environment (please complete the following information):
Output of uname -a
or ver
Darwin PT-320323-MBP16 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
Output of java -version
java version “11.0.9” 2020-10-20 LTS Java™ SE Runtime Environment 18.9 (build 11.0.9+7-LTS) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)
GraalVM version (if different from Java)
Quarkus version or git rev
1.12.2.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec Java version: 11.0.9, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.9.jdk/Contents/Home Default locale: en_PT, platform encoding: UTF-8 OS name: “mac os x”, version: “10.16”, arch: “x86_64”, family: “mac”
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
I can confirm that it’s a bug.
The Jandex
MethodParameterInfo
does not implementequals()/hashCode()
and for some reason we receive two distinct target instances for the@Observes
and@NormalEvent
annotations declared on the event param ofAbstractObserverNormalEvent.observer()
.I’ll prepare a fix next Monday.
@MarcoMartins86 FYI the problem only occurs if an observer method is declared on a class located in an archive with a pregenerated Jandex index (e.g. via the jandex-maven-plugin).