-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Bruno Navert opened SPR-5084 and commented
When using JDK proxies (proxy-target-class=false), it is not possible to use @RequestMapping to automatically define controllers.
This works very well if no proxying is involved. However, when AOP is used and a proxy of the controller is created (implementing the appropriate interface, where the interface has @RequestMapping at type and method level), then it fails.
The code in DefaultAnnotationHandlerMapping properly finds @RequestMapping at type level in the interface (since it uses AnnotationUtils.findAnnotation), but then it looks for method-level annotations in DefaultAnnotationHandlerMapping.determineUrlsForHandlerMethods()
This method only looks at the implementation class (the proxy), and finds no such annotation.
It should use the same kind of logic that AnnotationUtils does, and check the method declaration in the relevant interface(s) for any annotation there. Alternatively, perhaps declaring @RequestMapping as @Inheritable would suffice? Not sure. In any case, it should be simple to find the interfaces, get the right method, and check for annotations there.
The reason I prefer JDK proxies to CGLIB-based ones is because when we use CGLIB, it creates memory leaks when the application is reloaded in Tomcat, while JDK proxies don't have this problem.
Affects: 2.5.4
1 votes, 7 watchers