|
32 | 32 | import java.util.function.Consumer;
|
33 | 33 |
|
34 | 34 | import jakarta.validation.ValidatorFactory;
|
| 35 | +import org.aspectj.lang.JoinPoint; |
| 36 | +import org.aspectj.lang.annotation.AfterReturning; |
| 37 | +import org.aspectj.lang.annotation.Aspect; |
35 | 38 | import org.assertj.core.api.Assertions;
|
36 | 39 | import org.junit.jupiter.api.Test;
|
37 | 40 | import org.junit.jupiter.params.ParameterizedTest;
|
38 | 41 | import org.junit.jupiter.params.provider.ValueSource;
|
39 | 42 |
|
| 43 | +import org.springframework.aop.support.AopUtils; |
40 | 44 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
| 45 | +import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration; |
41 | 46 | import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
42 | 47 | import org.springframework.boot.autoconfigure.validation.ValidatorAdapter;
|
43 | 48 | import org.springframework.boot.autoconfigure.web.ServerProperties;
|
@@ -645,6 +650,17 @@ void problemDetailsEnabledAddsExceptionHandler() {
|
645 | 650 | .run((context) -> assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class));
|
646 | 651 | }
|
647 | 652 |
|
| 653 | + @Test |
| 654 | + void problemDetailsExceptionHandlerDoesNotPreventProxying() { |
| 655 | + this.contextRunner.withConfiguration(AutoConfigurations.of(AopAutoConfiguration.class)) |
| 656 | + .withBean(ExceptionHandlerInterceptor.class) |
| 657 | + .withPropertyValues("spring.webflux.problemdetails.enabled:true") |
| 658 | + .run((context) -> { |
| 659 | + assertThat(context).hasSingleBean(ProblemDetailsExceptionHandler.class); |
| 660 | + assertThat(AopUtils.isCglibProxy(context.getBean(ProblemDetailsExceptionHandler.class))); |
| 661 | + }); |
| 662 | + } |
| 663 | + |
648 | 664 | @Test
|
649 | 665 | void problemDetailsBacksOffWhenExceptionHandler() {
|
650 | 666 | this.contextRunner.withPropertyValues("spring.webflux.problemdetails.enabled:true")
|
@@ -957,4 +973,14 @@ static class CustomExceptionHandler extends ResponseEntityExceptionHandler {
|
957 | 973 |
|
958 | 974 | }
|
959 | 975 |
|
| 976 | + @Aspect |
| 977 | + static class ExceptionHandlerInterceptor { |
| 978 | + |
| 979 | + @AfterReturning(pointcut = "@annotation(org.springframework.web.bind.annotation.ExceptionHandler)", |
| 980 | + returning = "returnValue") |
| 981 | + void exceptionHandlerIntercept(JoinPoint joinPoint, Object returnValue) { |
| 982 | + } |
| 983 | + |
| 984 | + } |
| 985 | + |
960 | 986 | }
|
0 commit comments