Skip to content

Commit 44d6d6b

Browse files
committed
Close input stream resources (#514)
1 parent db1a32b commit 44d6d6b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

metafacture-io/src/main/java/org/metafacture/io/HttpOpener.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,21 @@ public void setBody(final String body) {
286286

287287
@Override
288288
public void process(final String input) {
289-
try {
290-
final String requestUrl = getInput(input, url);
291-
final String requestBody = getInput(input,
292-
body == null && method.getRequestHasBody() ? INPUT_DESIGNATOR : body);
289+
final String requestUrl = getInput(input, url);
290+
final String requestBody = getInput(input,
291+
body == null && method.getRequestHasBody() ? INPUT_DESIGNATOR : body);
293292

293+
try {
294294
final URL urlToOpen = new URL(requestUrl);
295295
final HttpURLConnection connection = requestBody != null ?
296296
doOutput(urlToOpen, requestBody) : doRedirects(urlToOpen);
297297

298298
final InputStream inputStream = getInputStream(connection);
299299
final String charset = getContentCharset(connection);
300-
301-
getReceiver().process(new InputStreamReader(
302-
"gzip".equalsIgnoreCase(connection.getContentEncoding()) ?
303-
new GZIPInputStream(inputStream) : inputStream, charset));
300+
final Reader reader = new InputStreamReader(
301+
"gzip".equalsIgnoreCase(connection.getContentEncoding()) ?
302+
new GZIPInputStream(inputStream) : inputStream, charset);
303+
getReceiver().process(reader);
304304
}
305305
catch (final IOException e) {
306306
throw new MetafactureException(e);

0 commit comments

Comments
 (0)