Browse Source

Close InputStream in finally block.

pull/57/head
Kalle Stenflo 10 years ago
parent
commit
313bf0b79b
  1. 6
      json-path/src/main/java/com/jayway/jsonpath/JsonPath.java
  2. 8
      json-path/src/main/java/com/jayway/jsonpath/internal/JsonReader.java

6
json-path/src/main/java/com/jayway/jsonpath/JsonPath.java

@ -330,11 +330,7 @@ public class JsonPath {
notNull(jsonInputStream, "json input stream can not be null");
notNull(configuration, "configuration can not be null");
try {
return read(jsonInputStream, "UTF-8", configuration);
} finally {
Utils.closeQuietly(jsonInputStream);
}
return read(jsonInputStream, "UTF-8", configuration);
}
/**

8
json-path/src/main/java/com/jayway/jsonpath/internal/JsonReader.java

@ -72,8 +72,12 @@ public class JsonReader implements ParseContext, ReadContext {
public ReadContext parse(InputStream json, String charset) {
notNull(json, "json input stream can not be null");
notNull(json, "charset can not be null");
this.json = configuration.jsonProvider().parse(json, charset);
return this;
try {
this.json = configuration.jsonProvider().parse(json, charset);
return this;
} finally {
Utils.closeQuietly(json);
}
}
@Override

Loading…
Cancel
Save