Merge branch 'pr-2401'

[doc] Update DoNotUseThreads rule documentation #2401
This commit is contained in:
Andreas Dangel
2020-04-06 20:21:32 +02:00
2 changed files with 25 additions and 4 deletions

View File

@ -56,6 +56,8 @@ Note that XPath 1.0 support, the default XPath version, is deprecated since PMD
* [#2390](https://github.com/pmd/pmd/issues/2390): \[java] AbstractClassWithoutAnyMethod: missing violation for nested classes
* java-errorprone
* [#2402](https://github.com/pmd/pmd/issues/2402): \[java] CloseResource possible false positive with Primitive Streams
* java-multithreading
* [#2313](https://github.com/pmd/pmd/issues/2313): \[java] Documenation for DoNotUseThreads is outdated
### API Changes
@ -131,6 +133,7 @@ implementations, and their corresponding Parser if it exists (in the same packag
* [#2395](https://github.com/pmd/pmd/pull/2395): \[apex] New Rule: Unused local variables - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2396](https://github.com/pmd/pmd/pull/2396): \[apex] New rule: field declarations should be at start - [Gwilym Kuiper](https://github.com/gwilymatgearset)
* [#2397](https://github.com/pmd/pmd/pull/2397): \[apex] fixed WITH SECURITY_ENFORCED regex to recognise line break characters - [Kieran Black](https://github.com/kieranlblack)
* [#2401](https://github.com/pmd/pmd/pull/2401): \[doc] Update DoNotUseThreads rule documentation - [Saikat Sengupta](https://github.com/s4ik4t)
* [#2403](https://github.com/pmd/pmd/pull/2403): \[java] #2402 fix false-positives on Primitive Streams - [Bernd Farka](https://github.com/BerndFarkaDyna)
{% endtocmaker %}

View File

@ -147,10 +147,28 @@ public class UsingThread extends Thread {
}
// Neither this,
public class OtherThread implements Runnable {
// Nor this ...
public void methode() {
Runnable thread = new Thread(); thread.run();
public class UsingExecutorService {
public void methodX() {
ExecutorService executorService = Executors.newFixedThreadPool(5);
}
}
// Nor this,
public class Example implements ExecutorService {
}
// Nor this,
public class Example extends AbstractExecutorService {
}
// Nor this
public class UsingExecutors {
public void methodX() {
Executors.newSingleThreadExecutor().submit(() -> System.out.println("Hello!"));
}
}
]]>