Skip to content

Commit

Permalink
Merge pull request #51 from cdapio/close
Browse files Browse the repository at this point in the history
Don't use Closeables.closeQuiently(inputStream)
  • Loading branch information
rmstar authored Feb 27, 2021
2 parents eec68de + efb2013 commit eb66906
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions common-http/src/main/java/io/cdap/common/http/HttpResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit eb66906

Please sign in to comment.