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; }