Affects: 5.0.7.RELEASE


On a RestController, it seems that exception handling does not work when the controller's class has bean proxied due to @PreAuthorize annotation.

In ExceptionHandlerExceptionResolver.java : the handled types to exception handlers mapping resolution uses proxied class instead of the original type (see line 455 : handlerMethod.getBeanType() )

The following (Kotlin) source code explain the problem (commenting the first line re-enable the exception handling... while disabling the security !)

    @PreAuthorize("hasAuthority('anyAuthority')")
    @RestController
    class AnyController : IAnyController {
        override fun doSomething(): ResponseEntity<AnyResponse> {
            throw ToBeHandledException()
        }

        @ExceptionHandler(ToBeHandledException::class)
        fun handleException(e: ToBeHandledException): ResponseEntity<Unit> =
            ResponseEntity.ok().build()
    }

Comment From: rstoyanchev

I am not able to reproduce the issue. Can you provide a sample?

In ExceptionHandlerExceptionResolver.java : the handled types to exception handlers mapping resolution uses proxied class instead of the original type (see line 455 : handlerMethod.getBeanType() )

The bean type is initialized with ClassUtils.getUserClass(bean). It should be okay.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.