Polish async method execution infrastructure
In anticipation of substantive changes required to implement @Async
executor qualification, the following updates have been made to the
components and infrastructure supporting @Async functionality:
- Fix trailing whitespace and indentation errors
- Fix generics warnings
- Add Javadoc where missing, update to use {@code} tags, etc.
- Avoid NPE in AopUtils#canApply
- Organize imports to follow conventions
- Remove System.out.println statements from tests
- Correct various punctuation and grammar problems
Issue: SPR-9443
Backport-Issue: SPR-6847
Backport-Commit: 3fb11870d9
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -18,8 +18,6 @@ package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
@@ -27,7 +25,8 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scheduling.annotation.AsyncResult;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
@@ -155,7 +154,6 @@ public class AsyncExecutionTests {
|
||||
|
||||
@Async
|
||||
public void doSomething(int i) {
|
||||
System.out.println(Thread.currentThread().getName() + ": " + i);
|
||||
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
|
||||
}
|
||||
|
||||
@@ -171,7 +169,6 @@ public class AsyncExecutionTests {
|
||||
public static class AsyncClassBean {
|
||||
|
||||
public void doSomething(int i) {
|
||||
System.out.println(Thread.currentThread().getName() + ": " + i);
|
||||
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
|
||||
}
|
||||
|
||||
@@ -194,7 +191,6 @@ public class AsyncExecutionTests {
|
||||
public static class AsyncInterfaceBean implements AsyncInterface {
|
||||
|
||||
public void doSomething(int i) {
|
||||
System.out.println(Thread.currentThread().getName() + ": " + i);
|
||||
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
|
||||
}
|
||||
|
||||
@@ -224,7 +220,6 @@ public class AsyncExecutionTests {
|
||||
}
|
||||
|
||||
public void doSomething(int i) {
|
||||
System.out.println(Thread.currentThread().getName() + ": " + i);
|
||||
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
|
||||
}
|
||||
|
||||
@@ -235,7 +230,7 @@ public class AsyncExecutionTests {
|
||||
}
|
||||
|
||||
|
||||
public static class AsyncMethodListener implements ApplicationListener {
|
||||
public static class AsyncMethodListener implements ApplicationListener<ApplicationEvent> {
|
||||
|
||||
@Async
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
@@ -246,7 +241,7 @@ public class AsyncExecutionTests {
|
||||
|
||||
|
||||
@Async
|
||||
public static class AsyncClassListener implements ApplicationListener {
|
||||
public static class AsyncClassListener implements ApplicationListener<ApplicationEvent> {
|
||||
|
||||
public AsyncClassListener() {
|
||||
listenerConstructed++;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -16,18 +16,15 @@
|
||||
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
@@ -39,6 +36,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests use of @EnableAsync on @Configuration classes.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user