diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java b/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java
index b602b8f4248..e03bedee72f 100644
--- a/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java
+++ b/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -24,41 +24,40 @@ import org.springframework.lang.Nullable;
/**
* Strategy interface for parsing known caching annotation types.
- * {@link AnnotationCacheOperationSource} delegates to such
- * parsers for supporting specific annotation types such as Spring's own
- * {@link Cacheable}, {@link CachePut} or {@link CacheEvict}.
+ * {@link AnnotationCacheOperationSource} delegates to such parsers
+ * for supporting specific annotation types such as Spring's own
+ * {@link Cacheable}, {@link CachePut} and{@link CacheEvict}.
*
* @author Costin Leau
* @author Stephane Nicoll
* @since 3.1
+ * @see AnnotationCacheOperationSource
+ * @see SpringCacheAnnotationParser
*/
public interface CacheAnnotationParser {
/**
- * Parses the cache definition for the given class,
- * based on a known annotation type.
- *
This essentially parses a known cache annotation into Spring's
- * metadata attribute class. Returns {@code null} if the class
- * is not cacheable.
+ * Parse the cache definition for the given class,
+ * based on an annotation type understood by this parser.
+ *
This essentially parses a known cache annotation into Spring's metadata
+ * attribute class. Returns {@code null} if the class is not cacheable.
* @param type the annotated class
- * @return CacheOperation the configured caching operation,
- * or {@code null} if none was found
+ * @return the configured caching operation, or {@code null} if none found
* @see AnnotationCacheOperationSource#findCacheOperations(Class)
*/
@Nullable
Collection parseCacheAnnotations(Class> type);
/**
- * Parses the cache definition for the given method,
- * based on a known annotation type.
- *
This essentially parses a known cache annotation into Spring's
- * metadata attribute class. Returns {@code null} if the method
- * is not cacheable.
+ * Parse the cache definition for the given method,
+ * based on an annotation type understood by this parser.
+ *
This essentially parses a known cache annotation into Spring's metadata
+ * attribute class. Returns {@code null} if the method is not cacheable.
* @param method the annotated method
- * @return CacheOperation the configured caching operation,
- * or {@code null} if none was found
+ * @return the configured caching operation, or {@code null} if none found
* @see AnnotationCacheOperationSource#findCacheOperations(Method)
*/
@Nullable
Collection parseCacheAnnotations(Method method);
+
}
diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
index 4b5cb59614c..3991969b3d8 100644
--- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
+++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
@@ -163,24 +163,22 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
/**
- * Subclasses need to implement this to return the caching attribute
- * for the given method, if any.
- * @param method the method to retrieve the attribute for
- * @return all caching attribute associated with this method
- * (or {@code null} if none)
+ * Subclasses need to implement this to return the caching attribute for the
+ * given class, if any.
+ * @param clazz the class to retrieve the attribute for
+ * @return all caching attribute associated with this class, or {@code null} if none
*/
@Nullable
- protected abstract Collection findCacheOperations(Method method);
+ protected abstract Collection findCacheOperations(Class> clazz);
/**
- * Subclasses need to implement this to return the caching attribute
- * for the given class, if any.
- * @param clazz the class to retrieve the attribute for
- * @return all caching attribute associated with this class
- * (or {@code null} if none)
+ * Subclasses need to implement this to return the caching attribute for the
+ * given method, if any.
+ * @param method the method to retrieve the attribute for
+ * @return all caching attribute associated with this method, or {@code null} if none
*/
@Nullable
- protected abstract Collection findCacheOperations(Class> clazz);
+ protected abstract Collection findCacheOperations(Method method);
/**
* Should only public methods be allowed to have caching semantics?
diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java
index b0dc5523498..6483bb0b4ed 100644
--- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java
+++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -96,7 +96,6 @@ public class EnableAsyncTests {
fail("Should have thrown UnsatisfiedDependencyException");
}
catch (UnsatisfiedDependencyException ex) {
- ex.printStackTrace();
assertTrue(ex.getCause() instanceof BeanNotOfRequiredTypeException);
}
}
@@ -111,7 +110,6 @@ public class EnableAsyncTests {
fail("Should have thrown UnsatisfiedDependencyException");
}
catch (UnsatisfiedDependencyException ex) {
- ex.printStackTrace();
assertTrue(ex.getCause() instanceof BeanNotOfRequiredTypeException);
}
}
@@ -218,8 +216,8 @@ public class EnableAsyncTests {
ctx.close();
}
- @Test
- public void spr14949FindsOnInterfaceWithInterfaceProxy() throws InterruptedException {
+ @Test // SPR-14949
+ public void findOnInterfaceWithInterfaceProxy() throws InterruptedException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14949ConfigA.class);
AsyncInterface asyncBean = ctx.getBean(AsyncInterface.class);
@@ -230,8 +228,8 @@ public class EnableAsyncTests {
ctx.close();
}
- @Test
- public void spr14949FindsOnInterfaceWithCglibProxy() throws InterruptedException {
+ @Test // SPR-14949
+ public void findOnInterfaceWithCglibProxy() throws InterruptedException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14949ConfigB.class);
AsyncInterface asyncBean = ctx.getBean(AsyncInterface.class);
diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java
index 2c2dd04170b..182c5f52810 100644
--- a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java
+++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java
@@ -135,14 +135,14 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
@Override
@Nullable
- protected TransactionAttribute findTransactionAttribute(Method method) {
- return determineTransactionAttribute(method);
+ protected TransactionAttribute findTransactionAttribute(Class> clazz) {
+ return determineTransactionAttribute(clazz);
}
@Override
@Nullable
- protected TransactionAttribute findTransactionAttribute(Class> clazz) {
- return determineTransactionAttribute(clazz);
+ protected TransactionAttribute findTransactionAttribute(Method method) {
+ return determineTransactionAttribute(method);
}
/**
diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java
index f9360ee5cf6..b2ebfc12363 100644
--- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java
+++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java
@@ -55,7 +55,13 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
* Canonical value held in cache to indicate no transaction attribute was
* found for this method, and we don't need to look again.
*/
- private static final TransactionAttribute NULL_TRANSACTION_ATTRIBUTE = new DefaultTransactionAttribute();
+ @SuppressWarnings("serial")
+ private static final TransactionAttribute NULL_TRANSACTION_ATTRIBUTE = new DefaultTransactionAttribute() {
+ @Override
+ public String toString() {
+ return "null";
+ }
+ };
/**
@@ -78,7 +84,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
*
Defaults to the class's transaction attribute if no method attribute is found.
* @param method the method for the current invocation (never {@code null})
* @param targetClass the target class for this invocation (may be {@code null})
- * @return TransactionAttribute for this method, or {@code null} if the method
+ * @return a TransactionAttribute for this method, or {@code null} if the method
* is not transactional
*/
@Override
@@ -90,7 +96,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
// First, see if we have a cached value.
Object cacheKey = getCacheKey(method, targetClass);
- Object cached = this.attributeCache.get(cacheKey);
+ TransactionAttribute cached = this.attributeCache.get(cacheKey);
if (cached != null) {
// Value will either be canonical value indicating there is no transaction attribute,
// or an actual transaction attribute.
@@ -98,7 +104,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
return null;
}
else {
- return (TransactionAttribute) cached;
+ return cached;
}
}
else {
@@ -182,25 +188,22 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
/**
- * Subclasses need to implement this to return the transaction attribute
- * for the given method, if any.
- * @param method the method to retrieve the attribute for
- * @return all transaction attribute associated with this method
- * (or {@code null} if none)
+ * Subclasses need to implement this to return the transaction attribute for the
+ * given class, if any.
+ * @param clazz the class to retrieve the attribute for
+ * @return all transaction attribute associated with this class, or {@code null} if none
*/
@Nullable
- protected abstract TransactionAttribute findTransactionAttribute(Method method);
+ protected abstract TransactionAttribute findTransactionAttribute(Class> clazz);
/**
- * Subclasses need to implement this to return the transaction attribute
- * for the given class, if any.
- * @param clazz the class to retrieve the attribute for
- * @return all transaction attribute associated with this class
- * (or {@code null} if none)
+ * Subclasses need to implement this to return the transaction attribute for the
+ * given method, if any.
+ * @param method the method to retrieve the attribute for
+ * @return all transaction attribute associated with this method, or {@code null} if none
*/
@Nullable
- protected abstract TransactionAttribute findTransactionAttribute(Class> clazz);
-
+ protected abstract TransactionAttribute findTransactionAttribute(Method method);
/**
* Should only public methods be allowed to have transactional semantics?
diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java
index 4f00f0d3d0a..348a5460b8a 100644
--- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java
+++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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,23 +31,23 @@ public class MapTransactionAttributeSource extends AbstractFallbackTransactionAt
private final Map