Details
-
Type:
Bug
-
Status: Resolved (View Workflow)
-
Priority:
Major
-
Resolution: Done
-
Affects Version/s: None
-
Fix Version/s: 3.0.0.Beta1
-
Component/s: Core
-
Labels:None
-
Estimated Difficulty:Low
Description
Qualifiers are meant to narrow the handlers that are invoked (in the same way as observers). Less specific handlers (particularly handlers without any qualifiers) should be notified if the set of qualifiers on the handler are a subset of the qualifiers on the exception payload. Currently Catch fails this assertion.
Let's assume that the following exception (of type Throwable) is sent to Catch:
beanManager.fireEvent(new ExceptionToCatch(e, new AnnotationLiteral<WebRequest>() {}));
The following two handlers should match:
void handleAny(@Handles CaughtException<Throwable> caught) {}
void handleForWebRequest(@Handles @WebRequest CaughtException<Throwable> caught) {}
However, the following handler would not be invoked because it's qualifiers are not a subset of the qualifiers on the exception payload:
void handleForRestRequest(@Handles @RestRequest CaughtException<Throwable> caught) {}
For reference, see JSR-299, Section 10.2.3: Multiple event qualifiers
Gliffy Diagrams
Issue Links
- relates to
-
CDI-7
Section 10.2, bullet 3, first paragraph contradicts the rest of the section
-
- Closed
-
I found the definitive sentence in the JSR-299 specification that supports this (chapter 10):
An observer method will be notified of an event if the event object is:
1. assignable to the observed event type and
2. all the qualifiers on the event observer are also event qualifiers of the event
Further clarified by 5.2
The type and qualifiers of the injection point are called the required type and required qualifiers.
That supports my claim that the qualifiers on the observer (in our case, handler) must be a subset of the qualifiers on the event (in our case, caught exception). There is one special case, @Any, which matches any qualifier set. @Any is implicit on an observer (in our case, handler) if no qualifiers are present.