Skip to content

Commit ad54e33

Browse files
fixes #242 Closes the response stream.
1 parent e649d0d commit ad54e33

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.io.IOException;
1717
import java.io.InputStream;
18+
import java.io.Reader;
1819
import java.util.logging.Level;
1920
import java.util.logging.Logger;
2021

@@ -99,8 +100,10 @@ public static JsonObject getJsonObject(String jsonString) {
99100
public static <T extends GenericModel> T getObject(Response response, Class<T> type) {
100101
JsonReader reader;
101102
try {
102-
reader = new JsonReader(response.body().charStream());
103+
Reader stream = response.body().charStream();
104+
reader = new JsonReader(stream);
103105
final T model = GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(reader, type);
106+
stream.close();
104107
return model;
105108
} catch (IOException e) {
106109
log.log(Level.SEVERE, ERROR_MESSAGE, e);

0 commit comments

Comments
 (0)