From b06d267232f3951e4d4bdbfbb04c4ce1d83f3b8c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 14 Dec 2021 13:56:28 +0100 Subject: [PATCH] Remove references to AsyncConfigurerSupport Closes gh-27812 --- .../scheduling/annotation/AsyncConfigurer.java | 8 +------- .../AsyncAnnotationBeanPostProcessorTests.java | 8 ++++---- ...gTestExecutionListenerIntegrationTests.java | 18 +++++++++++------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java index eab9744cf34..488297171ba 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +28,6 @@ import org.springframework.lang.Nullable; * {@link AsyncUncaughtExceptionHandler} instance used to process exception thrown from * async method with {@code void} return type. * - *

Consider using {@link AsyncConfigurerSupport} providing default implementations for - * both methods if only one element needs to be customized. Furthermore, backward compatibility - * of this interface will be insured in case new customization options are introduced - * in the future. - * *

See @{@link EnableAsync} for usage examples. * * @author Chris Beams @@ -40,7 +35,6 @@ import org.springframework.lang.Nullable; * @since 3.1 * @see AbstractAsyncConfiguration * @see EnableAsync - * @see AsyncConfigurerSupport */ public interface AsyncConfigurer { diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java index 477a97dec3d..2599d1a3cef 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -218,8 +218,8 @@ public class AsyncAnnotationBeanPostProcessorTests { private void assertFutureWithException(Future result, TestableAsyncUncaughtExceptionHandler exceptionHandler) { assertThatExceptionOfType(ExecutionException.class).isThrownBy( - result::get) - .withCauseExactlyInstanceOf(UnsupportedOperationException.class); + result::get) + .withCauseExactlyInstanceOf(UnsupportedOperationException.class); assertThat(exceptionHandler.isCalled()).as("handler should never be called with Future return type").isFalse(); } @@ -343,7 +343,7 @@ public class AsyncAnnotationBeanPostProcessorTests { @Configuration @EnableAsync - static class ConfigWithExceptionHandler extends AsyncConfigurerSupport { + static class ConfigWithExceptionHandler implements AsyncConfigurer { @Bean public ITestBean target() { diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java index c3edfeb8386..7cba9a36350 100644 --- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.AsyncConfigurerSupport; +import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; @@ -73,13 +73,17 @@ public class EventPublishingTestExecutionListenerIntegrationTests { private static final CountDownLatch countDownLatch = new CountDownLatch(1); private final TestContextManager testContextManager = new TestContextManager(ExampleTestCase.class); + private final TestContext testContext = testContextManager.getTestContext(); + // Note that the following invocation of getApplicationContext() forces eager // loading of the test's ApplicationContext which consequently results in the // publication of all test execution events. Otherwise, TestContext#publishEvent // would never fire any events for ExampleTestCase. private final TestExecutionListener listener = testContext.getApplicationContext().getBean(TestExecutionListener.class); + private final Object testInstance = new ExampleTestCase(); + private final Method traceableTestMethod = ReflectionUtils.findMethod(ExampleTestCase.class, "traceableTest"); @@ -127,8 +131,8 @@ public class EventPublishingTestExecutionListenerIntegrationTests { public void beforeTestMethodAnnotationWithFailingEventListener() throws Exception { Method method = ReflectionUtils.findMethod(ExampleTestCase.class, "testWithFailingEventListener"); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> - testContextManager.beforeTestMethod(testInstance, method)) - .withMessageContaining("Boom!"); + testContextManager.beforeTestMethod(testInstance, method)) + .withMessageContaining("Boom!"); verify(listener, only()).beforeTestMethod(testContext); } @@ -149,7 +153,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { verify(listener, only()).beforeTestMethod(testContext); assertThat(TrackingAsyncUncaughtExceptionHandler.asyncException.getMessage()) - .startsWith("Asynchronous exception for test method [" + methodName + "] in thread [" + THREAD_NAME_PREFIX); + .startsWith("Asynchronous exception for test method [" + methodName + "] in thread [" + THREAD_NAME_PREFIX); } @Test @@ -211,7 +215,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @Configuration @EnableAsync(proxyTargetClass = true) - static class TestEventListenerConfiguration extends AsyncConfigurerSupport { + static class TestEventListenerConfiguration implements AsyncConfigurer { @Override public Executor getAsyncExecutor() { @@ -306,7 +310,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { public void beforeTestMethodWithAsyncFailure(BeforeTestMethodEvent event) throws Exception { this.listener.beforeTestMethod(event.getSource()); throw new RuntimeException(String.format("Asynchronous exception for test method [%s] in thread [%s]", - event.getTestContext().getTestMethod().getName(), Thread.currentThread().getName())); + event.getTestContext().getTestMethod().getName(), Thread.currentThread().getName())); } }