|
10 | 10 | import java.util.concurrent.ExecutorService; |
11 | 11 | import java.util.concurrent.Executors; |
12 | 12 | import java.util.concurrent.Future; |
| 13 | +import java.util.concurrent.ThreadFactory; |
13 | 14 |
|
14 | 15 | import javax.ws.rs.ProcessingException; |
15 | 16 | import javax.ws.rs.client.Invocation.Builder; |
|
18 | 19 | import com.github.dockerjava.api.async.ResultCallback; |
19 | 20 | import com.github.dockerjava.core.async.ResponseStreamProcessor; |
20 | 21 | import com.github.dockerjava.jaxrs.util.WrappedResponseInputStream; |
| 22 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; |
21 | 23 |
|
22 | 24 | public abstract class AbstractCallbackNotifier<T> implements Callable<Void> { |
23 | 25 |
|
24 | 26 | private final ResponseStreamProcessor<T> responseStreamProcessor; |
25 | 27 |
|
26 | 28 | private final ResultCallback<T> resultCallback; |
27 | 29 |
|
| 30 | + private static final ThreadFactory FACTORY = |
| 31 | + new ThreadFactoryBuilder().setDaemon(true).setNameFormat("dockerjava-jaxrs-async-%d").build(); |
| 32 | + |
28 | 33 | protected final Builder requestBuilder; |
29 | 34 |
|
30 | 35 | protected AbstractCallbackNotifier(ResponseStreamProcessor<T> responseStreamProcessor, |
@@ -76,7 +81,7 @@ public Void call() throws Exception { |
76 | 81 |
|
77 | 82 | public static <T> Future<Void> startAsyncProcessing(AbstractCallbackNotifier<T> callbackNotifier) { |
78 | 83 |
|
79 | | - ExecutorService executorService = Executors.newSingleThreadExecutor(); |
| 84 | + ExecutorService executorService = Executors.newSingleThreadExecutor(FACTORY); |
80 | 85 | Future<Void> response = executorService.submit(callbackNotifier); |
81 | 86 | executorService.shutdown(); |
82 | 87 | return response; |
|
0 commit comments