From ae3cc67391af0d625d25fb8831c5475dfdfe95ed Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 2 Jun 2015 14:18:00 +0200 Subject: [PATCH] Lite configuration candidate check defensively handles method introspection failure Issue: SPR-13091 (cherry picked from commit 4f1286a) --- .../annotation/ConfigurationClassUtils.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java index c462fa1fc0e..93bc4efbc02 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -149,12 +149,24 @@ abstract class ConfigurationClassUtils { if (metadata.isInterface()) { return false; } + + // Any of the typical annotations found? for (String indicator : candidateIndicators) { if (metadata.isAnnotated(indicator)) { return true; } } - return metadata.hasAnnotatedMethods(Bean.class.getName()); + + // Finally, let's look for @Bean methods... + try { + return metadata.hasAnnotatedMethods(Bean.class.getName()); + } + catch (Throwable ex) { + if (logger.isDebugEnabled()) { + logger.debug("Failed to introspect @Bean methods on class [" + metadata.getClass() + "]: " + ex); + } + return false; + } } /**