From 1668a79f03dd1ff7cc3ba8e6eb17a324d41e47a6 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Fri, 23 Sep 2011 23:57:05 +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/branches/pmd/4.3.x@7323 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 3 ++ .../pmd/rules/basic/BasicRulesTest.java | 1 + .../pmd/rules/basic/xml/DontCallThreadRun.xml | 30 ++++++++++++++ pmd/rulesets/basic.xml | 41 +++++++++++++++++-- 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/DontCallThreadRun.xml diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 3b2ac54dbb..d24e9b194d 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -3,6 +3,9 @@ Add options --ignore-literals and --ignore-identifiers to the CPD command line task, thanks to Cd-Man Fixed character reference in xml report - thanks to Seko +New Rule: + basic: DontCallThreadRun - thanks to Andy Throgmorton + September 14, 2011 - 4.2.6: Fixed bug 2920057 - False + : CloseRessource whith an external getter Fixed bug 1808110 - Fixed performance issue on PreserveStackTrace diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/basic/BasicRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/basic/BasicRulesTest.java index f0f42c1db1..9d113b1ba5 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/basic/BasicRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/basic/BasicRulesTest.java @@ -45,6 +45,7 @@ public class BasicRulesTest extends SimpleAggregatorTst { addRule("basic", "UnnecessaryConversionTemporary"); addRule("basic", "UselessOperationOnImmutable"); addRule("basic", "UselessOverridingMethod"); + addRule("basic", "DontCallThreadRun"); } public static junit.framework.Test suite() { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/DontCallThreadRun.xml b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/DontCallThreadRun.xml new file mode 100644 index 0000000000..6ce4ed27c6 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/DontCallThreadRun.xml @@ -0,0 +1,30 @@ + + + + + 1 + + + + + 1 + + + diff --git a/pmd/rulesets/basic.xml b/pmd/rulesets/basic.xml index 482726ec6f..3228327722 100644 --- a/pmd/rulesets/basic.xml +++ b/pmd/rulesets/basic.xml @@ -1211,7 +1211,7 @@ public class Test { @@ -1240,6 +1240,41 @@ public class Foo { ]]> - + + +Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. + + 4 + + + + + + + + + + + -