@@ -503,12 +503,20 @@ public boolean isRemoveQueryParamOnRedirect() {
503
503
}
504
504
505
505
/**
506
- * Return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
507
- *
508
- * @return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
506
+ * @return <code> true</code> if both the application and reaper thread pools
507
+ * haven't yet been shutdown.
508
+ * @since 1.7.21
509
509
*/
510
- public boolean isClosed () {
511
- return applicationThreadPool .isShutdown () || reaper .isShutdown ();
510
+ public boolean isValid () {
511
+ boolean atpRunning = true ;
512
+ try {
513
+ atpRunning = applicationThreadPool .isShutdown ();
514
+ } catch (Exception ignore ) {
515
+ // isShutdown() will thrown an exception in an EE7 environment
516
+ // when using a ManagedExecutorService.
517
+ // When this is the case, we assume it's running.
518
+ }
519
+ return (atpRunning && !reaper .isShutdown ());
512
520
}
513
521
514
522
/**
@@ -1227,23 +1235,6 @@ public Thread newThread(Runnable r) {
1227
1235
});
1228
1236
}
1229
1237
1230
- // if (applicationThreadPool == null) {
1231
- // applicationThreadPool =
1232
- // Executors.newCachedThreadPool(new ThreadFactory() {
1233
- // final AtomicInteger counter = new AtomicInteger();
1234
- // public Thread newThread(Runnable r) {
1235
- // Thread t = new Thread(r,
1236
- // "AsyncHttpClient-Callback-" + counter.incrementAndGet());
1237
- // t.setDaemon(true);
1238
- // return t;
1239
- // }
1240
- // });
1241
- // }
1242
- //
1243
- // if (applicationThreadPool.isShutdown()) {
1244
- // throw new IllegalStateException("ExecutorServices closed");
1245
- // }
1246
-
1247
1238
if (proxyServerSelector == null && useProxySelector ) {
1248
1239
proxyServerSelector = ProxyUtils .getJdkDefaultProxyServerSelector ();
1249
1240
}
0 commit comments