From 4d20daf2e3ee9791e5402229693f7d43115a6286 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Fri, 23 Sep 2011 23:54:25 +0000 Subject: [PATCH] applied patch 2829888 : New rule: Calling Thread.run() - thanks to Andy Throgmorton git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7321 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 2 +- .../lang/java/rule/basic/BasicRulesTest.java | 3 +- .../java/rule/basic/xml/DontCallThreadRun.xml | 30 ++++++++++++++ pmd/rulesets/java/basic.xml | 39 +++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index db79143b88..c4ef9a478e 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -443,7 +443,7 @@ Fixed character reference in xml report - thanks to Seko New Java rules: - Basic ruleset: ExtendsObject,CheckSkipResult,AvoidBranchingStatementAsLastInLoop + Basic ruleset: ExtendsObject,CheckSkipResult,AvoidBranchingStatementAsLastInLoop,DontCallThreadRun Controversial ruleset: AvoidLiteralsInIfCondition, AvoidPrefixingMethodParameters, OneDeclarationPerLine, UseConcurrentHashMap Coupling ruleset: LoosePackageCoupling,LawofDemeter Design ruleset: LogicInversion,UseVarargs,FieldDeclarationsShouldBeAtStartOfClass,GodClass diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java index 55a0db2895..caf6299669 100644 --- a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/BasicRulesTest.java @@ -8,7 +8,7 @@ import org.junit.Before; import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst; public class BasicRulesTest extends SimpleAggregatorTst { - + private static final String RULESET = "java-basic"; @Before @@ -34,6 +34,7 @@ public class BasicRulesTest extends SimpleAggregatorTst { addRule(RULESET, "MisplacedNullCheck"); addRule(RULESET, "OverrideBothEqualsAndHashcode"); addRule(RULESET, "ReturnFromFinallyBlock"); + addRule(RULESET, "DontCallThreadRun"); } public static junit.framework.Test suite() { diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml new file mode 100644 index 0000000000..6ce4ed27c6 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/basic/xml/DontCallThreadRun.xml @@ -0,0 +1,30 @@ + + + + + 1 + + + + + 1 + + + diff --git a/pmd/rulesets/java/basic.xml b/pmd/rulesets/java/basic.xml index c20b6dc407..627d2a4124 100644 --- a/pmd/rulesets/java/basic.xml +++ b/pmd/rulesets/java/basic.xml @@ -736,6 +736,45 @@ for (int i = 0; i < 10; i++) { + + +Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. + + 4 + + + + + + + + + + + +