hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1206734 - /httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
Date Sun, 27 Nov 2011 15:28:29 GMT
Author: sebb
Date: Sun Nov 27 15:28:28 2011
New Revision: 1206734

URL: http://svn.apache.org/viewvc?rev=1206734&view=rev
Log:
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

Modified:
    httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java

Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java?rev=1206734&r1=1206733&r2=1206734&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpClient4.java
Sun Nov 27 15:28:28 2011
@@ -139,16 +139,16 @@ public class TestHttpClient4 implements 
                     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) {



Mime
View raw message