From efb2013a97ff731751cc65519226169b143302a6 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 26 Feb 2021 17:36:30 -0800 Subject: [PATCH] Don't use Closeables.closeQuiently(inputStream) This API was added in Guava 17.0, but we're using 13.0.1. --- .../java/io/cdap/common/http/HttpResponse.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common-http/src/main/java/io/cdap/common/http/HttpResponse.java b/common-http/src/main/java/io/cdap/common/http/HttpResponse.java index 6438c45..42979d1 100644 --- a/common-http/src/main/java/io/cdap/common/http/HttpResponse.java +++ b/common-http/src/main/java/io/cdap/common/http/HttpResponse.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Multimap; import com.google.common.io.ByteStreams; -import com.google.common.io.Closeables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -143,12 +142,23 @@ private byte[] getResponseBodyFromStream() { } catch (IOException e) { throw Throwables.propagate(e); } finally { - Closeables.closeQuietly(inputStream); + closeQuietly(inputStream); inputStream = null; conn.disconnect(); } } + private void closeQuietly(@Nullable InputStream inputStream) { + if (inputStream == null) { + return; + } + try { + inputStream.close(); + } catch (IOException e) { + LOG.warn("Failed to close input stream", e); + } + } + private boolean isSuccessful(int responseCode) { return 200 <= responseCode && responseCode < 300; }