Remove references to AsyncConfigurerSupport

Closes gh-27812
This commit is contained in:
Stephane Nicoll
2021-12-14 13:56:28 +01:00
parent 8422d9d22f
commit b06d267232
3 changed files with 16 additions and 18 deletions

View File

@@ -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.
*
* <p>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.
*
* <p>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 {

View File

@@ -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<Object> 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() {

View File

@@ -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()));
}
}