Skip to content

Commit 9a5b395

Browse files
committed
feat: attempt to figure out why thread pool is getting terminated
1 parent ba3edb9 commit 9a5b395

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

.github/workflows/pr.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
java: [11, 16]
19-
distribution: [ temurin, adopt-openj9 ]
20-
kubernetes: [ 'v1.17.13','v1.18.20','v1.19.14','v1.20.10','v1.21.4', 'v1.22.1' ]
18+
# java: [11, 16]
19+
java: [ 11 ]
20+
distribution: [ temurin ]
21+
kubernetes: [ 'v1.22.1' ]
22+
# distribution: [ temurin, adopt-openj9 ]
23+
# kubernetes: [ 'v1.17.13','v1.18.20','v1.19.14','v1.20.10','v1.21.4', 'v1.22.1' ]
2124
steps:
2225
- uses: actions/checkout@v2
2326
- name: Set up Java and Maven

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ExecutorServiceProducer.java

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3+
import java.util.concurrent.BlockingQueue;
34
import java.util.concurrent.ExecutorService;
4-
import java.util.concurrent.ScheduledThreadPoolExecutor;
5+
import java.util.concurrent.LinkedBlockingQueue;
6+
import java.util.concurrent.RejectedExecutionHandler;
7+
import java.util.concurrent.ThreadFactory;
8+
import java.util.concurrent.ThreadPoolExecutor;
9+
import java.util.concurrent.TimeUnit;
510
import java.util.concurrent.atomic.AtomicReference;
611

712
class ExecutorServiceProducer {
813

9-
private final static AtomicReference<ScheduledThreadPoolExecutor> executor =
14+
private final static AtomicReference<ThreadPoolExecutor> executor =
1015
new AtomicReference<>();
1116

1217
static ExecutorService getExecutor(int threadPoolSize) {
1318
final var gotSet =
14-
executor.compareAndSet(null, new ScheduledThreadPoolExecutor(threadPoolSize));
19+
executor.compareAndSet(null, new DebugThreadPoolExecutor(threadPoolSize, threadPoolSize, 0L,
20+
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()));
1521
final var result = executor.get();
1622
if (!gotSet) {
1723
// check that we didn't try to change the pool size
@@ -23,4 +29,37 @@ static ExecutorService getExecutor(int threadPoolSize) {
2329
}
2430
return result;
2531
}
32+
33+
private static class DebugThreadPoolExecutor extends ThreadPoolExecutor {
34+
35+
public DebugThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
36+
TimeUnit unit,
37+
BlockingQueue<Runnable> workQueue) {
38+
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
39+
}
40+
41+
public DebugThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
42+
TimeUnit unit, BlockingQueue<Runnable> workQueue,
43+
ThreadFactory threadFactory) {
44+
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
45+
}
46+
47+
public DebugThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
48+
TimeUnit unit, BlockingQueue<Runnable> workQueue,
49+
RejectedExecutionHandler handler) {
50+
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
51+
}
52+
53+
public DebugThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
54+
TimeUnit unit, BlockingQueue<Runnable> workQueue,
55+
ThreadFactory threadFactory, RejectedExecutionHandler handler) {
56+
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
57+
}
58+
59+
@Override
60+
public void shutdown() {
61+
Thread.dumpStack();
62+
super.shutdown();
63+
}
64+
}
2665
}

0 commit comments

Comments
 (0)