[FLINK-9580][rest] Close streams in RestClient#readRawResponse This closes #6166.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/b4574c9b Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/b4574c9b Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/b4574c9b Branch: refs/heads/master Commit: b4574c9bb5398713dd5501baf596f284ea19817f Parents: eb525b7 Author: yanghua <[email protected]> Authored: Thu Jun 14 16:16:20 2018 +0800 Committer: zentol <[email protected]> Committed: Wed Jun 27 22:01:16 2018 +0200 ---------------------------------------------------------------------- .../main/java/org/apache/flink/runtime/rest/RestClient.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/b4574c9b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java index c700807..2e1a784 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java @@ -415,16 +415,14 @@ public class RestClient { ByteBuf content = msg.content(); JsonNode rawResponse; - try { - InputStream in = new ByteBufInputStream(content); + try (InputStream in = new ByteBufInputStream(content)) { rawResponse = objectMapper.readTree(in); LOG.debug("Received response {}.", rawResponse); } catch (JsonParseException je) { LOG.error("Response was not valid JSON.", je); // let's see if it was a plain-text message instead content.readerIndex(0); - try { - ByteBufInputStream in = new ByteBufInputStream(content); + try (ByteBufInputStream in = new ByteBufInputStream(content)) { byte[] data = new byte[in.available()]; in.readFully(data); String message = new String(data);
