Skip to content

Commit dd59e6a

Browse files
committed
name the ForkJoinPool threads
fixes #4329
1 parent 4e4d206 commit dd59e6a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/OpenGrokThreadFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.indexer.configuration;
2424

@@ -33,6 +33,8 @@
3333
public class OpenGrokThreadFactory implements ThreadFactory {
3434
private final String threadPrefix;
3535

36+
public static final String PREFIX = "OpenGrok-";
37+
3638
public OpenGrokThreadFactory(String name) {
3739
if (!name.endsWith("-")) {
3840
threadPrefix = name + "-";
@@ -44,7 +46,7 @@ public OpenGrokThreadFactory(String name) {
4446
@Override
4547
public Thread newThread(@NotNull Runnable runnable) {
4648
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
47-
thread.setName("OpenGrok-" + threadPrefix + thread.getId());
49+
thread.setName(PREFIX + threadPrefix + thread.getId());
4850
return thread;
4951
}
5052
}

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexerParallelizer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.ExecutorService;
2727
import java.util.concurrent.Executors;
2828
import java.util.concurrent.ForkJoinPool;
29+
import java.util.concurrent.ForkJoinWorkerThread;
2930
import java.util.concurrent.ScheduledThreadPoolExecutor;
3031

3132
import org.opengrok.indexer.analysis.Ctags;
@@ -37,6 +38,8 @@
3738
import org.opengrok.indexer.util.ObjectFactory;
3839
import org.opengrok.indexer.util.ObjectPool;
3940

41+
import static java.util.concurrent.ForkJoinPool.defaultForkJoinWorkerThreadFactory;
42+
4043
/**
4144
* Represents a container for executors that enable parallelism for indexing
4245
* across projects and repositories and also within any {@link IndexDatabase}
@@ -230,7 +233,11 @@ private void bounceXrefWatcherExecutor() {
230233

231234
private void createLazyForkJoinPool() {
232235
lzForkJoinPool = LazilyInstantiate.using(() ->
233-
new ForkJoinPool(indexingParallelism));
236+
new ForkJoinPool(indexingParallelism, forkJoinPool -> {
237+
ForkJoinWorkerThread thread = defaultForkJoinWorkerThreadFactory.newThread(forkJoinPool);
238+
thread.setName(OpenGrokThreadFactory.PREFIX + "ForkJoinPool-" + thread.getId());
239+
return thread;
240+
}, null, false));
234241
}
235242

236243
private void createLazyCtagsPool() {

0 commit comments

Comments
 (0)