From 8f91869343991dd47add61bcdaf6beb234750d2b Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Sun, 27 Nov 2011 15:28:28 +0000 Subject: [PATCH] Not sure that instream can be null, but assuming it can, there's no point entering the try block if it's null. This avoids NPE warning git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1206734 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/client/benchmark/TestHttpClient4.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java index abe42c587..505e2455d 100644 --- a/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java +++ b/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java @@ -139,16 +139,16 @@ public class TestHttpClient4 implements TestHttpAgent { HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); - try { - contentLen = 0; - if (instream != null) { + contentLen = 0; + if (instream != null) { + try { int l = 0; while ((l = instream.read(buffer)) != -1) { contentLen += l; } + } finally { + instream.close(); } - } finally { - instream.close(); } } if (response.getStatusLine().getStatusCode() == 200) {