@@ -65,7 +65,7 @@ public final class DurableTaskGrpcWorker implements AutoCloseable {
6565 this .sidecarClient = TaskHubSidecarServiceGrpc .newBlockingStub (sidecarGrpcChannel );
6666 this .dataConverter = builder .dataConverter != null ? builder .dataConverter : new JacksonDataConverter ();
6767 this .maximumTimerInterval = builder .maximumTimerInterval != null ? builder .maximumTimerInterval : DEFAULT_MAXIMUM_TIMER_INTERVAL ;
68- this .workerPool = Executors . newCachedThreadPool () ;
68+ this .workerPool = builder . executorService ;
6969 }
7070
7171 /**
@@ -86,20 +86,8 @@ public void start() {
8686 * configured.
8787 */
8888 public void close () {
89- this .closeSideCarChannel ();
9089 this .shutDownWorkerPool ();
91- }
92-
93- private void closeSideCarChannel () {
94- if (this .managedSidecarChannel != null ) {
95- try {
96- this .managedSidecarChannel .shutdownNow ().awaitTermination (5 , TimeUnit .SECONDS );
97- } catch (InterruptedException e ) {
98- // Best effort. Also note that AutoClose documentation recommends NOT having
99- // close() methods throw InterruptedException:
100- // https://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html
101- }
102- }
90+ this .closeSideCarChannel ();
10391 }
10492
10593 /**
@@ -213,6 +201,18 @@ public void stop() {
213201 this .close ();
214202 }
215203
204+ private void closeSideCarChannel () {
205+ if (this .managedSidecarChannel != null ) {
206+ try {
207+ this .managedSidecarChannel .shutdownNow ().awaitTermination (5 , TimeUnit .SECONDS );
208+ } catch (InterruptedException e ) {
209+ // Best effort. Also note that AutoClose documentation recommends NOT having
210+ // close() methods throw InterruptedException:
211+ // https://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html
212+ }
213+ }
214+ }
215+
216216 private void shutDownWorkerPool () {
217217 this .workerPool .shutdown ();
218218 try {
0 commit comments