Skip to content

Commit 8a6e55c

Browse files
Merge pull request #34 from tsuyoshizawa/close-http-client
Add close method to Client
2 parents 1f9b833 + 1b28f29 commit 8a6e55c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/com/sendgrid/Client.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sendgrid;
22

3+
import java.io.Closeable;
34
import java.io.IOException;
45
import java.io.PrintWriter;
56
import java.io.StringWriter;
@@ -45,7 +46,7 @@ public HttpDeleteWithBody(final String uri) {
4546
/**
4647
* Class Client allows for quick and easy access any REST or REST-like API.
4748
*/
48-
public class Client {
49+
public class Client implements Closeable {
4950

5051
private CloseableHttpClient httpClient;
5152
private Boolean test;
@@ -342,12 +343,15 @@ public Response api(Request request) throws IOException {
342343
}
343344
}
344345

346+
@Override
347+
public void close() throws IOException {
348+
this.httpClient.close();
349+
}
350+
345351
@Override
346352
public void finalize() throws Throwable {
347353
try {
348-
if(this.createdHttpClient) {
349-
this.httpClient.close();
350-
}
354+
close();
351355
} catch(IOException e) {
352356
throw new Throwable(e.getMessage());
353357
} finally {

0 commit comments

Comments
 (0)