diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java index 33c669ee53..b8b32d82fc 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java @@ -42,7 +42,7 @@ import java.lang.annotation.Target; * @see AnnotationAsyncExecutionInterceptor * @see AsyncAnnotationAdvisor */ -@Target({ElementType.TYPE, ElementType.METHOD}) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Async { diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java index 48317d6eda..f5f0aca435 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java @@ -16,6 +16,8 @@ package org.springframework.scheduling.annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.concurrent.Future; import org.junit.Test; @@ -200,7 +202,7 @@ public class AsyncExecutionTests { assertTrue(Thread.currentThread().getName().startsWith("e1-")); } - @Async("e2") + @MyAsync public Future returnSomething(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); assertTrue(Thread.currentThread().getName().startsWith("e2-")); @@ -215,6 +217,12 @@ public class AsyncExecutionTests { } + @Async("e2") + @Retention(RetentionPolicy.RUNTIME) + public @interface MyAsync { + } + + @Async public static class AsyncClassBean {