diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt
index f8855233f6..c28d0ab5de 100644
--- a/pmd/etc/changelog.txt
+++ b/pmd/etc/changelog.txt
@@ -1,5 +1,6 @@
????, 2006 - 3.6:
New rules:
+ Basic ruleset: AvoidThreadGroup
Design ruleset: UnsynchronizedStaticDateFormatter
Strings ruleset: InefficientEmptyStringCheck, InsufficientStringBufferDeclaration
Fixed bug 1414985 - ConsecutiveLiteralAppends now checks for intervening references between appends.
diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/AvoidThreadGroupTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidThreadGroupTest.java
new file mode 100644
index 0000000000..1426b40357
--- /dev/null
+++ b/pmd/regress/test/net/sourceforge/pmd/rules/AvoidThreadGroupTest.java
@@ -0,0 +1,46 @@
+package test.net.sourceforge.pmd.rules;
+
+import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
+import test.net.sourceforge.pmd.testframework.TestDescriptor;
+import net.sourceforge.pmd.Rule;
+import net.sourceforge.pmd.RuleSetNotFoundException;
+import net.sourceforge.pmd.PMD;
+
+public class AvoidThreadGroupTest extends SimpleAggregatorTst {
+
+ private Rule rule;
+
+ public void setUp() throws RuleSetNotFoundException {
+ rule = findRule("basic", "AvoidThreadGroup");
+ }
+
+ public void testAll() {
+ runTests(new TestDescriptor[]{
+ new TestDescriptor(TEST1, "bad, using new ThreadGroup()", 1, rule),
+ new TestDescriptor(TEST2, "bad, using Thread.getThreadGroup()", 1, rule),
+ new TestDescriptor(TEST3, "bad, using System.getSecurityManager().getThreadGroup()", 1, rule),
+ });
+ }
+
+ private static final String TEST1 =
+ "public class Foo {" + PMD.EOL +
+ " void bar() {" + PMD.EOL +
+ " ThreadGroup t = new ThreadGroup(\"my tg\");" + PMD.EOL +
+ " }" + PMD.EOL +
+ "}";
+
+ private static final String TEST2 =
+ "public class Foo {" + PMD.EOL +
+ " void bar() {" + PMD.EOL +
+ " ThreadGroup t = Thread.currentThread().getThreadGroup();" + PMD.EOL +
+ " }" + PMD.EOL +
+ "}";
+
+ private static final String TEST3 =
+ "public class Foo {" + PMD.EOL +
+ " void bar() {" + PMD.EOL +
+ " ThreadGroup t = System.getSecurityManager().getThreadGroup();" + PMD.EOL +
+ " }" + PMD.EOL +
+ "}";
+
+}
diff --git a/pmd/rulesets/basic.xml b/pmd/rulesets/basic.xml
index a104da510d..19dd649fff 100644
--- a/pmd/rulesets/basic.xml
+++ b/pmd/rulesets/basic.xml
@@ -999,5 +999,39 @@ if (method1().equals(a)) {
+
+
+
+Avoid using ThreadGroup; although it is intended to be used in a threaded environment
+ it contains methods that are not thread safe.
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+
diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml
index c2dc36c3c6..a69c14d5f5 100644
--- a/pmd/xdocs/credits.xml
+++ b/pmd/xdocs/credits.xml
@@ -48,6 +48,7 @@
+ - Will Sargent - Implemented AvoidThreadGroup, AvoidThrowingCertainExceptionTypesRule, AvoidCatchingNPERule, ExceptionAsFlowControlRule, URL updates for 'Similar projects' page
- Xavier Le Vourch - Patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets
- Benoit Xhenseval - noted Maven plugin bug (http://jira.codehaus.org/browse/MPPMD-24), bug report for UnusedPrivateMethod, suggestion to add elapsed time to XML report, bug report for ImmutableField, many bug reports (with good failure cases!), Ant task patch and bug report, XSLT patch, suggestion for improving XML report
- Barak Naveh - Reported and fixed bug in CallSuperInConstructor
@@ -165,7 +166,6 @@
- Matt Inger - CloneMethodMustImplementCloneable, CloneThrowsCloneNotSupportedException
- Morgan Schweers - Javascript highlighter for the PMD scoreboard
- Brandon Franklin - bug report for BeanMembersShouldSerializeRule, many PMD scoreboard ideas
- - Will Sargent - AvoidThrowingCertainExceptionTypesRule, AvoidCatchingNPERule, ExceptionAsFlowControlRule, URL updates for 'Similar projects' page
- Bertrand Mollinier Toublet - Bug report which led to platform character set encoding enhancement
- Choi Ki Soo - Found bug in XMLRenderer
- Gero Wedemann - Found bug in RuleSetFactory XPath message variable substitution