Skip to content

Commit 741492c

Browse files
committed
Use named daemon threads for callback processing
1 parent 2d3fa91 commit 741492c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/com/github/dockerjava/jaxrs/async/AbstractCallbackNotifier.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.concurrent.ExecutorService;
1111
import java.util.concurrent.Executors;
1212
import java.util.concurrent.Future;
13+
import java.util.concurrent.ThreadFactory;
1314

1415
import javax.ws.rs.ProcessingException;
1516
import javax.ws.rs.client.Invocation.Builder;
@@ -18,13 +19,17 @@
1819
import com.github.dockerjava.api.async.ResultCallback;
1920
import com.github.dockerjava.core.async.ResponseStreamProcessor;
2021
import com.github.dockerjava.jaxrs.util.WrappedResponseInputStream;
22+
import com.google.common.util.concurrent.ThreadFactoryBuilder;
2123

2224
public abstract class AbstractCallbackNotifier<T> implements Callable<Void> {
2325

2426
private final ResponseStreamProcessor<T> responseStreamProcessor;
2527

2628
private final ResultCallback<T> resultCallback;
2729

30+
private static final ThreadFactory FACTORY =
31+
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("dockerjava-jaxrs-async-%d").build();
32+
2833
protected final Builder requestBuilder;
2934

3035
protected AbstractCallbackNotifier(ResponseStreamProcessor<T> responseStreamProcessor,
@@ -76,7 +81,7 @@ public Void call() throws Exception {
7681

7782
public static <T> Future<Void> startAsyncProcessing(AbstractCallbackNotifier<T> callbackNotifier) {
7883

79-
ExecutorService executorService = Executors.newSingleThreadExecutor();
84+
ExecutorService executorService = Executors.newSingleThreadExecutor(FACTORY);
8085
Future<Void> response = executorService.submit(callbackNotifier);
8186
executorService.shutdown();
8287
return response;

0 commit comments

Comments
 (0)