From 84e5982e30e9774dd6f6e1b15900d0fef04b48eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AA=8F=E7=83=88?= Date: Tue, 28 Nov 2017 17:29:58 +0800 Subject: [PATCH] transactional check pattern for rollbackFor or rollbakOn --- .../java/rule/exception/TransactionMustHaveRollbackRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java index 98cc89a..089778a 100644 --- a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java +++ b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java @@ -37,7 +37,7 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule { private static final String TRANSACTIONAL_ANNOTATION_NAME = "Transactional"; private static final String TRANSACTIONAL_FULL_NAME = "org.springframework.transaction.annotation." + TRANSACTIONAL_ANNOTATION_NAME; - private static final String ROLLBACK_FOR = "rollbackFor"; + private static final String ROLLBACK_PREFIX = "rollback"; private static final String XPATH_FOR_ROLLBACK = "//StatementExpression/PrimaryExpression" + "/PrimaryPrefix/Name[ends-with(@Image,'rollback')]"; @@ -82,7 +82,7 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule { private boolean rollbackAttrSet(List memberValuePairList) { for (ASTMemberValuePair pair : memberValuePairList) { - if (ROLLBACK_FOR.equals(pair.getImage())) { + if (pair.getImage() != null && pair.getImage().startsWith(ROLLBACK_PREFIX)) { return true; } } -- GitLab