Affects: Spring-webmvc 5.1.8.RELEASE

Description: The latest changes in the AbstractHandlerMapping and DispatcherServlet in the commit 28a5c3009ea0c31f879c0bb8b9e6cfd33faa81e5 bring to null pointer exception if RequestMappingHandlerMapping is a proxy created by CGLIB because the logger field is null for proxy object: Screen Shot 2019-08-27 at 4 58 02 PM

To reproduce that behavior I created code snippet: https://github.com/smoomrik/code-snippets/tree/master/proxy-target-class-logger-nullpointer

it contains 3 tags: - 5.0.7_wide_scope: Spring version is 5.0.7.Release. The aspect has a wide scope that force to replace RequestMappingHandlerMapping with proxy created by CGLIB. It works (not fine but it doesn't break anything) - 5.1.8_wide_scope: Spring version is 5.1.8.Release. The aspect has a wide scope that force to replace RequestMappingHandlerMapping with proxy created by CGLIB. It doesn't work (null pointer exception because the logger field is null) - 5.1.8_small_scope: Spring version is 5.1.8.Release. The aspect has a limited to package scope that removes needs for proxying RequestMappingHandlerMapping. It works fine.

I know the usage of so wide scope for aspects is wrong, but the question is: - Is it expected that Spring allows proxying RequestMappingHandlerMapping in the version 5.0.7 without any problems and allow but bring to the unusable state in the version 5.1.8?

I supposed there is some kind of protection logic to avoid proxying of Spring internals. Isn't it?

@rstoyanchev could you please take a look.

Comment From: snicoll

This is never going to work I am afraid. CGLIB proxies have limitation in what they can or cannot do and having an aspect like this was never meant to work. The field is probably null as it's trying to invoke a private method that doesn't route to the target object.