jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1743467 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Date Thu, 12 May 2016 06:09:21 GMT
Author: pmouawad
Date: Thu May 12 06:09:21 2016
New Revision: 1743467

URL: http://svn.apache.org/viewvc?rev=1743467&view=rev
Log:
Bug 59489 - Regression in JMeter 3.0 : Compressed responses break keepalive management 
Take into account sebb note
INstanciate ArrayList only when needed
Bugzilla Id: 59489

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1743467&r1=1743466&r2=1743467&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Thu May 12 06:09:21 2016
@@ -205,7 +205,7 @@ public class HTTPHC4Impl extends HTTPHCA
         @Override
         public void process(HttpResponse response, HttpContext context)
                 throws HttpException, IOException {
-            ArrayList<Header[]> headersToSave = new ArrayList<>(3);
+            ArrayList<Header[]> headersToSave = null;
             
             final HttpEntity entity = response.getEntity();
             final HttpClientContext clientContext = HttpClientContext.adapt(context);
@@ -214,6 +214,7 @@ public class HTTPHC4Impl extends HTTPHCA
             if (requestConfig.isContentCompressionEnabled() && entity != null &&
entity.getContentLength() != 0) {
                 final Header ceheader = entity.getContentEncoding();
                 if (ceheader != null) {
+                    headersToSave = new ArrayList<>(3);
                     for(String name : HEADERS_TO_SAVE) {
                         Header[] hdr = response.getHeaders(name); // empty if none
                         headersToSave.add(hdr);
@@ -224,9 +225,14 @@ public class HTTPHC4Impl extends HTTPHCA
             // Now invoke original parent code
             super.process(response, clientContext);
             // Should this be in a finally ? 
-            for (Header[] headers : headersToSave) {
-                for (Header headerToRestore : headers) {
-                    response.addHeader(headerToRestore);                    
+            if(headersToSave != null) {
+                for (Header[] headers : headersToSave) {
+                    for (Header headerToRestore : headers) {
+                        if (response.containsHeader(headerToRestore.getName())) {
+                            break;
+                        }
+                        response.addHeader(headerToRestore);
+                    }
                 }
             }
         }



Mime
View raw message