Add mappedHandler Predicate to AbstractHandlerExceptionResolver

Closes gh-26772
This commit is contained in:
rstoyanchev
2023-12-05 11:46:10 +00:00
parent 753409083d
commit dd23b1d156
2 changed files with 49 additions and 14 deletions

View File

@@ -385,6 +385,21 @@ public class ExceptionHandlerExceptionResolverTests {
assertExceptionHandledAsBody(mav, "DefaultTestExceptionResolver: IllegalStateException");
}
@Test // gh-26772
void resolveExceptionViaMappedHandlerPredicate() throws Exception {
Object handler = new Object();
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MyControllerAdviceConfig.class);
this.resolver.setMappedHandlerPredicate(h -> h == handler);
this.resolver.setApplicationContext(ctx);
this.resolver.afterPropertiesSet();
ModelAndView mav = this.resolver.resolveException(
this.request, this.response, handler, new IllegalStateException());
assertExceptionHandledAsBody(mav, "DefaultTestExceptionResolver: IllegalStateException");
}
private void assertMethodProcessorCount(int resolverCount, int handlerCount) {
assertThat(this.resolver.getArgumentResolvers().getResolvers()).hasSize(resolverCount);