Java: Add java/javautilconcurrentscheduledthreadpoolexecutor query for zero thread pool size

This commit is contained in:
Tamas Vajk
2025-06-23 11:59:55 +02:00
parent 12cda86141
commit 60e726bdf2
7 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
| Test.java:7:42:7:75 | new ScheduledThreadPoolExecutor(...) | ScheduledThreadPoolExecutor.corePoolSize is set to have 0 threads. |
| Test.java:8:9:8:28 | setCorePoolSize(...) | ScheduledThreadPoolExecutor.corePoolSize is set to have 0 threads. |
| Test.java:9:9:9:28 | setCorePoolSize(...) | ScheduledThreadPoolExecutor.corePoolSize is set to have 0 threads. |

View File

@@ -0,0 +1,2 @@
query: Likely Bugs/Concurrency/ScheduledThreadPoolExecutorZeroThread.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -0,0 +1,11 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
public class Test {
void f() {
int i = 0;
ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(1); // Compliant
ScheduledThreadPoolExecutor s1 = new ScheduledThreadPoolExecutor(0); // $ Alert
s.setCorePoolSize(0); // $ Alert
s.setCorePoolSize(i); // $ Alert
}
}