Name the thread pool used by ChangeHookRunner

All threads should be named from their source location (roughly)
to help identify who creates the thread and what their purpose is.
Having thread pools named aids troubleshooting when looking at
jstack output.

Change-Id: Ia0e3f3c4781203d27702544268b91abe9e9e15be
This commit is contained in:
Shawn Pearce
2013-07-29 22:33:57 -07:00
committed by Dave Borowitz
parent a206e11fad
commit 7c571aae52

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.common;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes;
@@ -213,7 +214,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
private final SitePaths sitePaths;
/** Thread pool used to monitor sync hooks */
private final ExecutorService syncHookThreadPool = Executors.newCachedThreadPool();
private final ExecutorService syncHookThreadPool;
/** Timeout value for synchronous hooks */
private final int syncHookTimeout;
@@ -262,6 +263,10 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
claSignedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "claSignedHook", "cla-signed")).getPath());
refUpdateHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "refUpdateHook", "ref-update")).getPath());
syncHookTimeout = config.getInt("hooks", "syncHookTimeout", 30);
syncHookThreadPool = Executors.newCachedThreadPool(
new ThreadFactoryBuilder()
.setNameFormat("SyncHook-%d")
.build());
}
public void addChangeListener(ChangeListener listener, IdentifiedUser user) {