Skip to content

Commit 74a21de

Browse files
committed
1 parent b51442c commit 74a21de

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.io.InputStream;
3131
import java.util.Collection;
3232
import java.util.Map;
33+
import java.util.concurrent.ExecutorService;
34+
import java.util.concurrent.Executors;
3335
import java.util.concurrent.Future;
3436
import java.util.concurrent.atomic.AtomicBoolean;
3537

@@ -370,11 +372,16 @@ public void close() {
370372
* Asynchronous close the {@link AsyncHttpProvider} by spawning a thread and avoid blocking.
371373
*/
372374
public void closeAsynchronously() {
373-
config.applicationThreadPool.submit(new Runnable() {
374-
375+
final ExecutorService e = Executors.newSingleThreadExecutor();
376+
e.submit(new Runnable() {
375377
public void run() {
376-
httpProvider.close();
377-
isClosed.set(true);
378+
try {
379+
close();
380+
} catch (Throwable t) {
381+
logger.warn("", t);
382+
} finally {
383+
e.shutdown();
384+
}
378385
}
379386
});
380387
}

0 commit comments

Comments
 (0)