Skip to content

Commit 53b1e5d

Browse files
committed
PMD: Reword and also apply to runAsync
1 parent deddd91 commit 53b1e5d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.config/pmd/java/ruleset.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@ public class GoodPerson implements Comparable<Person> {
841841
Solution: Use a dedicated thread pool with enough threads to get proper parallelism.
842842
The number of threads in the common pool is equal to the number of CPUs and meant to utilize all of them.
843843
It assumes CPU-intensive non-blocking processing of in-memory data.
844+
845+
See also: [_Be Aware of ForkJoinPool#commonPool()_](https://dzone.com/articles/be-aware-of-forkjoinpoolcommonpool)
844846
</description>
845847
<priority>2</priority>
846848
<properties>
@@ -897,22 +899,25 @@ public class Foo {
897899

898900
<rule name="AvoidCommonPoolForFutureAsync"
899901
language="java"
900-
message="Avoid using the common thread pool for Future.supplyAsync, use a separate pool"
902+
message="Avoid using the common thread pool, use a separate pool"
901903
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
902904
<description>
903-
Future.supplyAsync is typically used for remote calls. By default, it uses the common pool.
905+
CompletableFuture.supplyAsync/runAsync is typically used for remote calls.
906+
By default it uses the common pool.
904907
The number of threads in the common pool is equal to the number of CPU's, which is suitable for in-memory processing.
905908
For I/O, however, this number is typically not suitable because most time is spent waiting for the response and not in CPU.
906909
The common pool must not be used for blocking calls.
907910

908-
Solution: A separate, properly sized, pool of threads (an Executor) should be used for the async calls.
911+
Solution: A separate, properly sized pool of threads (an Executor) should be used for the async calls.
912+
913+
See also: [_Be Aware of ForkJoinPool#commonPool()_](https://dzone.com/articles/be-aware-of-forkjoinpoolcommonpool)
909914
</description>
910915
<priority>2</priority>
911916
<properties>
912917
<property name="xpath">
913918
<value>
914919
<![CDATA[
915-
//MethodCall[pmd-java:matchesSig('java.util.concurrent.CompletableFuture#supplyAsync(_)')]
920+
//MethodCall[pmd-java:matchesSig('java.util.concurrent.CompletableFuture#supplyAsync(_)') or pmd-java:matchesSig('java.util.concurrent.CompletableFuture#runAsync(_)')]
916921
]]>
917922
</value>
918923
</property>

0 commit comments

Comments
 (0)