Skip to content

Commit d4ec320

Browse files
committed
1 parent 3897106 commit d4ec320

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/main/java/com/ning/http/client/AsyncHttpClientConfig.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,29 @@ public boolean isRemoveQueryParamOnRedirect() {
447447
* Return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
448448
*
449449
* @return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
450+
*
451+
* @deprecated use #isValid
450452
*/
451453
public boolean isClosed() {
452-
return applicationThreadPool.isShutdown() || reaper.isShutdown();
454+
return !isValid();
455+
}
456+
457+
/**
458+
* @return <code>true</code> if both the application and reaper thread pools
459+
* haven't yet been shutdown.
460+
*
461+
* @since 1.7.21
462+
*/
463+
public boolean isValid() {
464+
boolean atpRunning = true;
465+
try {
466+
atpRunning = applicationThreadPool.isShutdown();
467+
} catch (Exception ignore) {
468+
// isShutdown() will thrown an exception in an EE7 environment
469+
// when using a ManagedExecutorService.
470+
// When this is the case, we assume it's running.
471+
}
472+
return (atpRunning && !reaper.isShutdown());
453473
}
454474

455475
/**
@@ -1123,10 +1143,6 @@ public Thread newThread(Runnable r) {
11231143
});
11241144
}
11251145

1126-
if (applicationThreadPool.isShutdown()) {
1127-
throw new IllegalStateException("ExecutorServices closed");
1128-
}
1129-
11301146
if (proxyServerSelector == null && useProxySelector) {
11311147
proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
11321148
}

0 commit comments

Comments
 (0)