Apply name-matching transaction attributes to user-level methods only

In particular, do not apply them to GroovyObject methods and other kinds of synthetic methods in language runtimes. The only exception are bridge methods since those do eventually point to a user-level generic method.

Issue: SPR-10803
This commit is contained in:
Juergen Hoeller
2013-10-30 12:38:45 +01:00
parent 0fe49629c0
commit 4bcfbc3ba3
3 changed files with 27 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -19,6 +19,7 @@ package org.springframework.transaction.interceptor;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
/**
@@ -52,7 +53,7 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
@Override
public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) {
return this.transactionAttribute;
return (ClassUtils.isUserLevelMethod(method) ? this.transactionAttribute : null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -26,6 +26,7 @@ import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.PatternMatchUtils;
@@ -100,7 +101,11 @@ public class NameMatchTransactionAttributeSource implements TransactionAttribute
@Override
public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) {
// look for direct name match
if (!ClassUtils.isUserLevelMethod(method)) {
return null;
}
// Look for direct name match.
String methodName = method.getName();
TransactionAttribute attr = this.nameMap.get(methodName);