Skip to content

Commit ae3cc67

Browse files
committed
Lite configuration candidate check defensively handles method introspection failure
Issue: SPR-13091 (cherry picked from commit 4f1286a)
1 parent 55de4a6 commit ae3cc67

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -149,12 +149,24 @@ public static boolean isLiteConfigurationCandidate(AnnotationMetadata metadata)
149149
if (metadata.isInterface()) {
150150
return false;
151151
}
152+
153+
// Any of the typical annotations found?
152154
for (String indicator : candidateIndicators) {
153155
if (metadata.isAnnotated(indicator)) {
154156
return true;
155157
}
156158
}
157-
return metadata.hasAnnotatedMethods(Bean.class.getName());
159+
160+
// Finally, let's look for @Bean methods...
161+
try {
162+
return metadata.hasAnnotatedMethods(Bean.class.getName());
163+
}
164+
catch (Throwable ex) {
165+
if (logger.isDebugEnabled()) {
166+
logger.debug("Failed to introspect @Bean methods on class [" + metadata.getClass() + "]: " + ex);
167+
}
168+
return false;
169+
}
158170
}
159171

160172
/**

0 commit comments

Comments
 (0)