Author: sebb
Date: Tue Dec  7 13:38:30 2010
New Revision: 1043043

URL: http://svn.apache.org/viewvc?rev=1043043&view=rev
Log:
Localise variables

Modified:
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1043043&r1=1043042&r2=1043043&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
 Tue Dec  7 13:38:30 2010
@@ -198,8 +198,6 @@ public class HTTPHC3Impl extends HTTPHCA
         res.setURL(url);
 
         res.sampleStart(); // Count the retries as well in the time
-        HttpClient client = null;
-        InputStream instream = null;
         try {
             // May generate IllegalArgumentException
             if (method.equals(POST)) {
@@ -232,8 +230,9 @@ public class HTTPHC3Impl extends HTTPHCA
 
             // Set any default request headers
             setDefaultRequestHeaders(httpMethod);
+
             // Setup connection
-            client = setupConnection(url, httpMethod, res);
+            HttpClient client = setupConnection(url, httpMethod, res);
             savedClient = client;
 
             // Handle the various methods
@@ -251,15 +250,18 @@ public class HTTPHC3Impl extends HTTPHCA
             res.setRequestHeaders(getConnectionHeaders(httpMethod));
 
             // Request sent. Now get the response:
-            instream = httpMethod.getResponseBodyAsStream();
+            InputStream instream = httpMethod.getResponseBodyAsStream();
 
             if (instream != null) {// will be null for HEAD
-
-                Header responseHeader = 
httpMethod.getResponseHeader(HEADER_CONTENT_ENCODING);
-                if (responseHeader!= null && 
ENCODING_GZIP.equals(responseHeader.getValue())) {
-                    instream = new GZIPInputStream(instream);
+                try {
+                    Header responseHeader = 
httpMethod.getResponseHeader(HEADER_CONTENT_ENCODING);
+                    if (responseHeader!= null && 
ENCODING_GZIP.equals(responseHeader.getValue())) {
+                        instream = new GZIPInputStream(instream);
+                    }
+                    res.setResponseData(readResponse(res, instream, (int) 
httpMethod.getResponseContentLength()));
+                } finally {
+                    JOrphanUtils.closeQuietly(instream);
                 }
-                res.setResponseData(readResponse(res, instream, (int) 
httpMethod.getResponseContentLength()));
             }
 
             res.sampleEnd();
@@ -326,7 +328,6 @@ public class HTTPHC3Impl extends HTTPHCA
             return err;
         } finally {
             savedClient = null;
-            JOrphanUtils.closeQuietly(instream);
             if (httpMethod != null) {
                 httpMethod.releaseConnection();
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to