-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WELD-2775 Make sure BM#getEvent() adds @Default qualifier correctly #2907
Conversation
tests-arquillian/src/test/java/org/jboss/weld/tests/event/ObservingBean.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Although I don't think the requirement for BM#getEvent()
is correct. It should be more like BM#createInstance()
...
I agree, but for now this is what we're stuck with 🤷 |
.addQualifiers(qualifiers) | ||
.addQualifierUnchecked(QualifierInstance.ANY).create(); | ||
.addQualifierUnchecked(QualifierInstance.ANY); | ||
if (qualifiers.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder (here and in EventMetadataImpl
), what if qualifiers
contains @Any
(and nothing else)?
These are event qualifiers, so @Any
is always present (that is, there's no difference between user specifying @Any
and user not specifying @Any
), so perhaps @Default
should be added too in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder (here and in
EventMetadataImpl
), what ifqualifiers
contains@Any
(and nothing else)?These are event qualifiers, so
@Any
is always present (that is, there's no difference between user specifying@Any
and user not specifying@Any
), so perhaps@Default
should be added too in this case?
Why? If you do @Inject @Any Event<Foo> event
and then event.fire(new Foo())
then the @Default
should not be present, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder (here and in
EventMetadataImpl
), what ifqualifiers
contains@Any
(and nothing else)?
Had the same idea and my previous version of this code did exactly what you're suggesting but there were TCKs failures.
IIRC it was the EventMetadataTest#testSimpleEvent
which doesn't expect @Default
to be present when you use something like @Inject @Any Event<SimpleEvent>
and fire event from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that makes sense. @Inject Event<Foo>
is equivalent to @Inject @Default Event<Foo>
, so the set of specified qualifiers is {@Default}
and the set of event qualifiers is {@Default, @Any}
.
So the qualifiers here are not event qualifiers, they are specified qualifiers.
The problem is that
slightly different behaviour applies to observers with @default qualifier
...
Such observer will only be notified for events having either no qualifiers or only@Default
qualifier
talks about event qualifiers (which are never {}
or {@Default}
), even though it probably should talk about specified qualifiers (which are also never {}
, but may be {@Default}
).
(Technically, that paragraph should probably never have been added. Looking at the history, this was an attempt to clarify that @Inject Event<Foo>
is equivalent to @Inject @Default Event<Foo>
due to how injection points work, but that attempt unintentionally added a new provision to the specification that triggers in some weird situation. I actually don't know what that situation is anymore, considering that BM.getEvent()
should unconditionally add @Default
to the set of specified qualifiers...)
Also maybe fix the comment at |
I still think the an empty set makes the most sense - this is just a representation of a synthetic IP in case it gets introspected (via |
No, that's just an implementation comment. Why are you explicitly adding |
Ok, I'll change it to:
|
Attempts to fix the missing
@Default
qualifier when firing events viaBeanManager.getEvent()
API.