Skip to content

Commit ce0e245

Browse files
committed
Implement Closeable where relevant
This helps to advertise closeability of resource.
1 parent c9b680e commit ce0e245

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

api/src/main/java/com/ning/http/client/AsyncHttpProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*/
1616
package com.ning.http.client;
1717

18+
import java.io.Closeable;
1819
import java.io.IOException;
1920
import java.util.List;
2021

2122
/**
2223
* Interface to be used when implementing custom asynchronous I/O HTTP client.
2324
* By default, the {@link com.ning.http.client.providers.netty.NettyAsyncHttpProvider} is used.
2425
*/
25-
public interface AsyncHttpProvider {
26+
public interface AsyncHttpProvider extends Closeable {
2627

2728
/**
2829
* Execute the request and invoke the {@link AsyncHandler} when the response arrive.

api/src/main/java/com/ning/http/client/Body.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
package com.ning.http.client;
1515

16+
import java.io.Closeable;
1617
import java.io.IOException;
1718
import java.nio.ByteBuffer;
1819

1920
/**
2021
* A request body.
2122
*/
22-
public interface Body {
23+
public interface Body extends Closeable {
2324

2425
/**
2526
* Gets the length of the body.

api/src/main/java/com/ning/http/client/BodyConsumer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
package com.ning.http.client;
1515

16+
import java.io.Closeable;
1617
import java.io.IOException;
1718
import java.nio.ByteBuffer;
1819

1920
/**
2021
* A simple API to be used with the {@link SimpleAsyncHttpClient} class in order to process response's bytes.
2122
*/
22-
public interface BodyConsumer {
23+
public interface BodyConsumer extends Closeable {
2324

2425
/**
2526
* Consume the received bytes.

api/src/main/java/com/ning/http/client/SimpleAsyncHttpClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.slf4j.LoggerFactory;
2121

2222
import javax.net.ssl.SSLContext;
23+
24+
import java.io.Closeable;
2325
import java.io.IOException;
2426
import java.util.Collection;
2527
import java.util.Map;
@@ -57,7 +59,7 @@
5759
* Future<Response> future = client.post(new FileodyGenerator(myFile), new OutputStreamBodyConsumer(o));
5860
* </pre></blockquote>
5961
*/
60-
public class SimpleAsyncHttpClient {
62+
public class SimpleAsyncHttpClient implements Closeable {
6163

6264
private final static Logger logger = LoggerFactory.getLogger(SimpleAsyncHttpClient.class);
6365
private final AsyncHttpClientConfig config;

0 commit comments

Comments
 (0)