diff --git a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java index d7692e27a..0a58fe699 100644 --- a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java +++ b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java @@ -11,6 +11,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Generated; + import com.alibaba.p3c.pmd.lang.java.util.NumberConstants; import com.alibaba.p3c.pmd.lang.java.util.StringAndCharConstants; @@ -77,6 +79,7 @@ * @author unknown * @date 2016/11/21 */ +@Generated("from pmd") public class FixClassTypeResolver extends ClassTypeResolver { private static final Logger LOG = Logger.getLogger(FixClassTypeResolver.class.getName()); 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 089778a64..1de7c61e9 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 @@ -39,6 +39,8 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule { + TRANSACTIONAL_ANNOTATION_NAME; private static final String ROLLBACK_PREFIX = "rollback"; + private static final String PROPAGATION_NOT_SUPPORTED = "Propagation.NOT_SUPPORTED"; + private static final String XPATH_FOR_ROLLBACK = "//StatementExpression/PrimaryExpression" + "/PrimaryPrefix/Name[ends-with(@Image,'rollback')]"; @@ -53,7 +55,7 @@ public Object visit(ASTAnnotation node, Object data) { return super.visit(node, data); } List memberValuePairList = node.findDescendantsOfType(ASTMemberValuePair.class); - if (rollbackAttrSet(memberValuePairList)) { + if (shouldSkip(memberValuePairList)) { return super.visit(node, data); } @@ -80,9 +82,16 @@ public Object visit(ASTAnnotation node, Object data) { return super.visit(node, data); } - private boolean rollbackAttrSet(List memberValuePairList) { + private boolean shouldSkip(List memberValuePairList) { for (ASTMemberValuePair pair : memberValuePairList) { - if (pair.getImage() != null && pair.getImage().startsWith(ROLLBACK_PREFIX)) { + if (pair.getImage() == null) { + continue; + } + if (pair.getImage().startsWith(ROLLBACK_PREFIX)) { + return true; + } + ASTName name = pair.getFirstDescendantOfType(ASTName.class); + if (name != null && PROPAGATION_NOT_SUPPORTED.equals(name.getImage())) { return true; } }