Skip to content

Commit d55c4e0

Browse files
committed
Port changes from AsyncHttpClient#402 to master.
1 parent 48b75f5 commit d55c4e0

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,20 @@ public boolean isRemoveQueryParamOnRedirect() {
503503
}
504504

505505
/**
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
509509
*/
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());
512520
}
513521

514522
/**
@@ -1227,23 +1235,6 @@ public Thread newThread(Runnable r) {
12271235
});
12281236
}
12291237

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-
12471238
if (proxyServerSelector == null && useProxySelector) {
12481239
proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
12491240
}

0 commit comments

Comments
 (0)