Fix NPE for @Indexed in the MessagingGatewayReg

The `@Indexed` comes without any attributes, but it is included
into a chain via `importingClassMetadata.getMetaAnnotationTypes(ann)`.
So, skip attributes from meta annotation when it is `null`

**Cherry-pick to `5.4.x` & `5.3.x`**
This commit is contained in:
Artem Bilan
2021-07-01 15:28:06 -04:00
parent 46acf0cc83
commit 836a11be6a
2 changed files with 4 additions and 2 deletions

View File

@@ -45,7 +45,6 @@ import org.springframework.stereotype.Indexed;
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
public @interface MessagingGateway {

View File

@@ -199,7 +199,10 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
Set<String> chain = importingClassMetadata.getMetaAnnotationTypes(ann);
if (chain.contains(MessagingGateway.class.getName())) {
for (String meta : chain) {
valuesHierarchy.add(importingClassMetadata.getAllAnnotationAttributes(meta));
MultiValueMap<String, Object> attributes = importingClassMetadata.getAllAnnotationAttributes(meta);
if (attributes != null) {
valuesHierarchy.add(attributes);
}
}
}
}