81
81
import org .glassfish .grizzly .ssl .SSLEngineConfigurator ;
82
82
import org .glassfish .grizzly .ssl .SSLFilter ;
83
83
import org .glassfish .grizzly .strategies .SameThreadIOStrategy ;
84
+ import org .glassfish .grizzly .strategies .WorkerThreadIOStrategy ;
84
85
import org .glassfish .grizzly .utils .BufferOutputStream ;
85
86
import org .glassfish .grizzly .utils .DelayedExecutor ;
86
87
import org .glassfish .grizzly .utils .IdleTimeoutFilter ;
104
105
import java .util .Map ;
105
106
import java .util .concurrent .Callable ;
106
107
import java .util .concurrent .ExecutionException ;
108
+ import java .util .concurrent .ExecutorService ;
107
109
import java .util .concurrent .Semaphore ;
108
110
import java .util .concurrent .TimeUnit ;
109
111
import java .util .concurrent .TimeoutException ;
@@ -225,6 +227,10 @@ public void close() {
225
227
try {
226
228
connectionManager .destroy ();
227
229
clientTransport .stop ();
230
+ final ExecutorService service = clientConfig .executorService ();
231
+ if (service != null ) {
232
+ service .shutdown ();
233
+ }
228
234
if (timeoutExecutor != null ) {
229
235
timeoutExecutor .stop ();
230
236
}
@@ -277,8 +283,6 @@ protected <T> ListenableFuture<T> execute(final Connection c,
277
283
278
284
279
285
protected void initializeTransport (AsyncHttpClientConfig clientConfig ) {
280
-
281
-
282
286
283
287
final FilterChainBuilder fcb = FilterChainBuilder .stateless ();
284
288
fcb .add (new AsyncHttpClientTransportFilter ());
@@ -354,7 +358,7 @@ public void onTimeout(Connection connection) {
354
358
}
355
359
fcb .add (eventFilter );
356
360
fcb .add (clientFilter );
357
-
361
+
358
362
GrizzlyAsyncHttpProviderConfig providerConfig =
359
363
(GrizzlyAsyncHttpProviderConfig ) clientConfig .getAsyncHttpProviderConfig ();
360
364
if (providerConfig != null ) {
@@ -363,10 +367,10 @@ public void onTimeout(Connection connection) {
363
367
if (customizer != null ) {
364
368
customizer .customize (clientTransport , fcb );
365
369
} else {
366
- clientTransport . setIOStrategy ( SameThreadIOStrategy . getInstance () );
370
+ doDefaultTransportConfig ( );
367
371
}
368
372
} else {
369
- clientTransport . setIOStrategy ( SameThreadIOStrategy . getInstance () );
373
+ doDefaultTransportConfig ( );
370
374
}
371
375
372
376
clientTransport .setProcessor (fcb .build ());
@@ -401,6 +405,16 @@ void touchConnection(final Connection c, final Request request) {
401
405
402
406
403
407
// --------------------------------------------------------- Private Methods
408
+
409
+ private void doDefaultTransportConfig () {
410
+ final ExecutorService service = clientConfig .executorService ();
411
+ if (service != null ) {
412
+ clientTransport .setIOStrategy (WorkerThreadIOStrategy .getInstance ());
413
+ clientTransport .setWorkerThreadPool (service );
414
+ } else {
415
+ clientTransport .setIOStrategy (SameThreadIOStrategy .getInstance ());
416
+ }
417
+ }
404
418
405
419
406
420
private <T > CompletionHandler <WriteResult > createWriteCompletionHandler (final GrizzlyResponseFuture <T > future ) {
0 commit comments