From 6c89946d421b37b4fed9218958d354cade5cdea2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Nov 2009 16:55:13 +0000 Subject: [PATCH] leniently fall back to the passed-in method if a bridge method couldn't be resolved (for Groovy 1.7 compatibility) --- .../core/BridgeMethodResolver.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 4adf3acac6d..fac0d787519 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -53,7 +53,9 @@ public abstract class BridgeMethodResolver { *

It is safe to call this method passing in a non-bridge {@link Method} instance. * In such a case, the supplied {@link Method} instance is returned directly to the caller. * Callers are not required to check for bridging before calling this method. - * @throws IllegalStateException if no bridged {@link Method} can be found + * @param bridgeMethod the method to introspect + * @return the original method (either the bridged method or the passed-in method + * if no more specific one could be found) */ public static Method findBridgedMethod(Method bridgeMethod) { if (bridgeMethod == null || !bridgeMethod.isBridge()) { @@ -72,12 +74,16 @@ public abstract class BridgeMethodResolver { return candidateMethods.get(0); } // Search for candidate match. - Method result = searchCandidates(candidateMethods, bridgeMethod); - if (result == null) { - throw new IllegalStateException( - "Unable to locate bridged method for bridge method '" + bridgeMethod + "'"); + Method bridgedMethod = searchCandidates(candidateMethods, bridgeMethod); + if (bridgedMethod != null) { + // Bridged method found... + return bridgedMethod; + } + else { + // A bridge method was passed in but we couldn't find the bridged method. + // Let's proceed with the passed-in method and hope for the best... + return bridgeMethod; } - return result; } /**