Skip to content

Commit c85127d

Browse files
committed
TransactionAttributeSourcePointcut pointcut skips target classes with TransactionalProxy marker (e.g. Spring Data proxies)
Issue: SPR-13109
1 parent 846fae2 commit c85127d

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,9 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi
3434

3535
@Override
3636
public boolean matches(Method method, Class<?> targetClass) {
37+
if (TransactionalProxy.class.isAssignableFrom(targetClass)) {
38+
return false;
39+
}
3740
TransactionAttributeSource tas = getTransactionAttributeSource();
3841
return (tas == null || tas.getTransactionAttribute(method, targetClass) != null);
3942
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2002-2015 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.transaction.interceptor;
18+
19+
import org.springframework.aop.SpringProxy;
20+
21+
/**
22+
* A marker interface for manually created transactional proxies.
23+
*
24+
* <p>{@link TransactionAttributeSourcePointcut} will ignore such existing
25+
* transactional proxies during AOP auto-proxying and therefore avoid
26+
* re-processing transaction metadata on them.
27+
*
28+
* @author Juergen Hoeller
29+
* @since 4.1.7
30+
*/
31+
public interface TransactionalProxy extends SpringProxy {
32+
33+
}

0 commit comments

Comments
 (0)