File tree 1 file changed +21
-5
lines changed
src/main/java/com/ning/http/client 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -447,9 +447,29 @@ public boolean isRemoveQueryParamOnRedirect() {
447
447
* Return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
448
448
*
449
449
* @return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
450
+ *
451
+ * @deprecated use #isValid
450
452
*/
451
453
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 ());
453
473
}
454
474
455
475
/**
@@ -1123,10 +1143,6 @@ public Thread newThread(Runnable r) {
1123
1143
});
1124
1144
}
1125
1145
1126
- if (applicationThreadPool .isShutdown ()) {
1127
- throw new IllegalStateException ("ExecutorServices closed" );
1128
- }
1129
-
1130
1146
if (proxyServerSelector == null && useProxySelector ) {
1131
1147
proxyServerSelector = ProxyUtils .getJdkDefaultProxyServerSelector ();
1132
1148
}
You can’t perform that action at this time.
0 commit comments