jdaugherty opened a new pull request, #16467:
URL: https://github.com/apache/grails-core/pull/16467

   ## Problem
   
   `GrailsInterceptorHandlerInterceptorAdapter.afterCompletion` reads the 
request `exception` attribute with an `(Exception)` cast when no completion 
exception is passed in. The cast throws `ClassCastException` when that 
attribute holds:
   
   - an `Error`, such as `ExceptionInInitializerError` or `AssertionError`
   - a plain `Throwable`
   - a value that is not a `Throwable`, for example a String placed in a 
forward's model, whose entries are copied into request attributes
   
   The `ClassCastException` hides the original failure, and `afterView` is 
skipped for every matched interceptor.
   
   ## Fix
   
   - Read the attribute as `Object` and use it only when it is a `Throwable`. 
Other values are ignored, so `afterView` always runs.
   - An explicit completion exception still takes precedence over the request 
attribute.
   - `Interceptor.throwable` can now expose an `Error` as well as an 
`Exception`. The Groovydoc and the interceptors guide say so.
   
   ## Tests
   
   New cases in `GrailsInterceptorHandlerInterceptorAdapterSpec`:
   
   - `afterView` receives the original checked exception, runtime exception, 
initializer error, assertion error, plain `Throwable`, or null.
   - A String or Map in the attribute is ignored and `afterView` still runs.
   - Every matched interceptor receives the error.
   - An explicit completion exception wins over the request attribute.
   
   Module suite: 109 tests, 0 failures. Mutation check: the original 
`(Exception)` cast fails 6 of the new cases, and a widened `(Throwable)` cast 
fails the 2 non-Throwable cases.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to