Skip to content
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

Arc - Add null check when trying to load qualifier class #41514

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,12 @@ static boolean hasQualifier(BeanDeployment beanDeployment, AnnotationInstance re
//as this is called in a tight loop we only do it if necessary
values = new ArrayList<>();
Set<String> nonBindingFields = beanDeployment.getQualifierNonbindingMembers(requiredQualifier.name());
if (requiredClazz == null) {
throw new IllegalStateException("Failed to find bean qualifier class with name "
+ requiredQualifier.name() + " in application index. Make sure the class is part of "
+ "the Jandex index. Classes that are not subject to discovery can be registered via "
+ "AdditionalBeanBuildItem and non-qualifier annotations can use QualifierRegistrarBuildItem");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not seeing this sooner -- IMHO this block should be roughly 10 lines above, directly beneath the declaration of requiredClazz. It makes no sense to do this check deep in a loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's only executed once because the values are initialized lazily... so I thought that it's not always needed and therefore it's ok to check it in the loop, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's only executed once because the values are initialized lazily... so I thought that it's not always needed and therefore it's ok to check it in the loop, or?

Yea, that^ was my thinking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, there's no problem with that, and I didn't mean to imply that it's checked multiple times. It just feels better to be checked directly beneath the declaration rather than 10 lines below, in the middle of an unrelated loop. But it's OK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"It makes no sense to do this check deep in a loop" VS "It just feels better to be checked directly beneath the declaration" 😄

for (AnnotationValue val : requiredQualifier.valuesWithDefaults(beanDeployment.getBeanArchiveIndex())) {
if (!requiredClazz.method(val.name()).hasAnnotation(DotNames.NONBINDING)
&& !nonBindingFields.contains(val.name())) {
Expand Down
Loading