Strong references to mapped exception handler methods

Issue: SPR-15907
This commit is contained in:
Juergen Hoeller
2017-08-29 15:07:23 +02:00
parent b122bc6dcc
commit 2b44e6e21c
4 changed files with 19 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,7 +51,7 @@ public class ExceptionHandlerMethodResolver {
(AnnotationUtils.findAnnotation(method, ExceptionHandler.class) != null);
private final Map<Class<? extends Throwable>, Method> mappedMethods = new ConcurrentReferenceHashMap<>(16);
private final Map<Class<? extends Throwable>, Method> mappedMethods = new HashMap<>(16);
private final Map<Class<? extends Throwable>, Method> exceptionLookupCache = new ConcurrentReferenceHashMap<>(16);
@@ -83,7 +84,9 @@ public class ExceptionHandlerMethodResolver {
}
}
}
Assert.notEmpty(result, "No exception types mapped to {" + method + "}");
if (result.isEmpty()) {
throw new IllegalStateException("No exception types mapped to " + method);
}
return result;
}