RetryingTransactionInterceptor was bypassing all nested interceptors

- The code did this:
        return method.invoke(target.getThis(), target.getArguments());
   rather than this:
        return target.proceed();
 - Services that used this are PublishingService, ChannelService, TransferService and
   old CMIS dmServicesProxyCreator
 - None of the above are adversely affected because the first 3 don't apply permissions
   and the last one uses the interceptor in reverse order
 - BUT: None of the aforementioned services will be auditable!


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32276 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-11-24 12:57:29 +00:00
parent 9e7c10abd0
commit c0203199af

View File

@@ -18,7 +18,6 @@
*/ */
package org.alfresco.repo.transaction; package org.alfresco.repo.transaction;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
@@ -46,36 +45,27 @@ public class RetryingTransactionInterceptor extends TransactionAspectSupport imp
if ((null != target) && (null != target.getThis()) && (null != target.getMethod())) if ((null != target) && (null != target.getThis()) && (null != target.getMethod()))
{ {
final Method method = target.getMethod(); final Method method = target.getMethod();
final TransactionAttribute transactionAttribute = getTransactionAttributeSource().getTransactionAttribute(method, target.getThis().getClass()); final TransactionAttribute txnAttr = getTransactionAttributeSource().getTransactionAttribute(method, target.getThis().getClass());
if (null != transactionAttribute) if (null != txnAttr && txnAttr.getPropagationBehavior() != TransactionAttribute.PROPAGATION_SUPPORTS)
{ {
return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>() RetryingTransactionCallback<Object> txnCallback = new RetryingTransactionCallback<Object>()
{ {
@Override
public Object execute() throws Throwable public Object execute() throws Throwable
{ {
try return target.proceed();
{
return method.invoke(target.getThis(), target.getArguments());
}
catch (InvocationTargetException e)
{
if (null != e.getTargetException())
{
throw e.getTargetException();
}
else
{
throw new AlfrescoRuntimeException(e.getMessage(), e);
}
}
} }
}, transactionAttribute.isReadOnly(), (TransactionAttribute.PROPAGATION_REQUIRES_NEW == transactionAttribute.getPropagationBehavior())); };
return transactionService.getRetryingTransactionHelper().doInTransaction(
txnCallback,
txnAttr.isReadOnly(),
(TransactionAttribute.PROPAGATION_REQUIRES_NEW == txnAttr.getPropagationBehavior()));
} }
else else
{ {
return method.invoke(target.getThis(), target.getArguments()); return target.proceed();
} }
} }
throw new AlfrescoRuntimeException("Invalid undefined MethodInvocation instance"); throw new AlfrescoRuntimeException("Invalid or undefined MethodInvocation instance: " + target.getMethod());
} }
} }