Skip to content

Commit

Permalink
Merge pull request #46107 from gsmet/fix-artemis-npe
Browse files Browse the repository at this point in the history
For synthetic injection points, target can be null
  • Loading branch information
geoand authored Feb 6, 2025
2 parents ec343c7 + 8c182c0 commit d03dcca
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,19 @@ void validateConfigMappingsInjectionPoints(
if (configClass != null) {
AnnotationTarget target = injectionPoint.getAnnotationTarget();
AnnotationInstance mapping = null;
if (target.kind().equals(FIELD)) {
mapping = target.asField().annotation(CONFIG_MAPPING_NAME);
} else if (target.kind().equals(METHOD_PARAMETER)) {
MethodParameterInfo methodParameterInfo = target.asMethodParameter();
if (methodParameterInfo.type().name().equals(type.name())) {
Set<AnnotationInstance> parameterAnnotations = getParameterAnnotations(
validationPhase.getBeanProcessor().getBeanDeployment(),
target.asMethodParameter().method(), methodParameterInfo.position());
mapping = Annotations.find(parameterAnnotations, CONFIG_MAPPING_NAME);

// target can be null for synthetic injection point
if (target != null) {
if (target.kind().equals(FIELD)) {
mapping = target.asField().annotation(CONFIG_MAPPING_NAME);
} else if (target.kind().equals(METHOD_PARAMETER)) {
MethodParameterInfo methodParameterInfo = target.asMethodParameter();
if (methodParameterInfo.type().name().equals(type.name())) {
Set<AnnotationInstance> parameterAnnotations = getParameterAnnotations(
validationPhase.getBeanProcessor().getBeanDeployment(),
target.asMethodParameter().method(), methodParameterInfo.position());
mapping = Annotations.find(parameterAnnotations, CONFIG_MAPPING_NAME);
}
}
}

Expand Down

0 comments on commit d03dcca

Please sign in to comment.