sonatype/async-http-client — Issue #44: Should AsyncHttpClient implement AutoCloseable / Closeable?
Author: bclozel
Created: 2012-01-27 22:10:43+00:00
State: open

Looking into [try with resources](http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html), I've been wondering.

### Should AsyncHttpClient implement AutoCloseable?

[AutoCloseable](http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html) interface only comes with java 1.7+, so that would break backwards compatibility for a small feature...

### Should AsyncHttpClient implement Closeable?

[Closeable](http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html) is a subinterface of AutoCloseable and comes with java 1.5+, so compatibility should not be an issue. But this interface says:

void close() throws IOException

So we're breaking here the existing API (the current API doesn't throw any exception on `close()`).

- People should subclass AsyncHttpClient and implement one of these if they feel the need to?
- The "try with resource" statement doesn't play nicely with async?