From 0cc77e812cb40bb9ddc504402ac163fb6f7425ad Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 14 Feb 2019 10:16:32 +0100 Subject: [PATCH] Polish "Ensure indexer gracefully handle missing meta annotations" Closes gh-22385 --- .../springframework/context/index/processor/TypeHelper.java | 3 ++- .../context/index/sample/cdi/SampleTransactional.java | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java index c8791a53ad..78ef1bc6ae 100644 --- a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java +++ b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java @@ -114,7 +114,8 @@ class TypeHelper { try { return this.env.getElementUtils().getAllAnnotationMirrors(e); } - catch (Throwable ex) { + catch (Exception ex) { + // This may fail if one of the annotation is not available return Collections.emptyList(); } } diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/cdi/SampleTransactional.java b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/cdi/SampleTransactional.java index 909a61a6a2..e318cd9a75 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/cdi/SampleTransactional.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/cdi/SampleTransactional.java @@ -19,9 +19,12 @@ package org.springframework.context.index.sample.cdi; import javax.transaction.Transactional; /** - * Test candidate for {@link Transactional}. + * Test candidate for {@link Transactional}. This verifies that the annotation processor + * can process an annotation that declares itself an annotation that is not on the + * classpath. * * @author Vedran Pavic + * @author Stephane Nicoll */ @Transactional public class SampleTransactional {