@ExceptionHandler works for inherited method and CGLIB proxies on Portlet controllers as well (SPR-7337)

This commit is contained in:
Juergen Hoeller
2010-07-08 11:45:35 +00:00
parent cb72fe1be2
commit 7e9e8401f7
2 changed files with 26 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ import javax.portlet.WindowState;
import org.springframework.core.ExceptionDepthComparator;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.ui.Model;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -136,10 +137,11 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
}
else {
Method oldMappedMethod = resolverMethods.get(handledException);
throw new IllegalStateException(
"Ambiguous exception handler mapped for " + handledException + "]: {" +
oldMappedMethod + ", " + method + "}.");
if (!oldMappedMethod.equals(method)) {
throw new IllegalStateException(
"Ambiguous exception handler mapped for " + handledException + "]: {" +
oldMappedMethod + ", " + method + "}.");
}
}
}
}
@@ -160,7 +162,7 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
@SuppressWarnings("unchecked")
protected List<Class<? extends Throwable>> getHandledExceptions(Method method) {
List<Class<? extends Throwable>> result = new ArrayList<Class<? extends Throwable>>();
ExceptionHandler exceptionHandler = method.getAnnotation(ExceptionHandler.class);
ExceptionHandler exceptionHandler = AnnotationUtils.findAnnotation(method, ExceptionHandler.class);
if (exceptionHandler != null) {
if (!ObjectUtils.isEmpty(exceptionHandler.value())) {
result.addAll(Arrays.asList(exceptionHandler.value()));