hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1206731 - /httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
Date Sun, 27 Nov 2011 15:25:54 GMT
Author: sebb
Date: Sun Nov 27 15:25:53 2011
New Revision: 1206731

URL: http://svn.apache.org/viewvc?rev=1206731&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/TestHttpCore.java

Modified: httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java?rev=1206731&r1=1206730&r2=1206731&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/TestHttpCore.java
Sun Nov 27 15:25:53 2011
@@ -180,18 +180,18 @@ public class TestHttpCore implements Tes
                         httpexecutor.postProcess(response, httpproc, context);
 
                         HttpEntity entity = response.getEntity();
-                        if (entity != null) {
+                        if (entity != null) { // TODO can this be null?
                             InputStream instream = entity.getContent();
-                            try {
+                            if (instream != null) {
                                 contentLen = 0;
-                                if (instream != null) {
-                                    int l = 0;
-                                    while ((l = instream.read(buffer)) != -1) {
-                                        contentLen += l;
-                                    }
+                                try {
+                                        int l = 0;
+                                        while ((l = instream.read(buffer)) != -1) {
+                                            contentLen += l;
+                                        }
+                                } finally {
+                                    instream.close();
                                 }
-                            } finally {
-                                instream.close();
                             }
                         }
                         if (connStrategy.keepAlive(response, context)) {



Mime
View raw message