jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1728420 - in /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler: HTTPHC3Impl.java HTTPHC4Impl.java
Date Thu, 04 Feb 2016 08:20:17 GMT
Author: pmouawad
Date: Thu Feb  4 08:20:17 2016
New Revision: 1728420

URL: http://svn.apache.org/viewvc?rev=1728420&view=rev
Log:
http samplers : reorder the http method in the switch, move the most common ones first
Add debug log when setting keep alive
Call close on HttpClient
#resolve #105

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
    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/HTTPHC3Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1728420&r1=1728419&r2=1728420&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Thu Feb  4 08:20:17 2016
@@ -213,6 +213,8 @@ public class HTTPHC3Impl extends HTTPHCA
             // May generate IllegalArgumentException
             if (method.equals(HTTPConstants.POST)) {
                 httpMethod = new PostMethod(urlStr);
+            } else if (method.equals(HTTPConstants.GET)){
+                httpMethod = new GetMethod(urlStr);
             } else if (method.equals(HTTPConstants.PUT)){
                 httpMethod = new PutMethod(urlStr);
             } else if (method.equals(HTTPConstants.HEAD)){
@@ -228,8 +230,6 @@ public class HTTPHC3Impl extends HTTPHCA
                         return HTTPConstants.DELETE;
                     }
                 };
-            } else if (method.equals(HTTPConstants.GET)){
-                httpMethod = new GetMethod(urlStr);
             } else if (method.equals(HTTPConstants.PATCH)){
                 httpMethod = new EntityEnclosingMethod(urlStr) {
                     @Override

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=1728420&r1=1728419&r2=1728420&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 Feb  4 08:20:17 2016
@@ -102,9 +102,9 @@ import org.apache.http.params.DefaultedH
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.SyncBasicHttpParams;
 import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpCoreContext;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpCoreContext;
 import org.apache.jmeter.protocol.http.control.AuthManager;
 import org.apache.jmeter.protocol.http.control.CacheManager;
 import org.apache.jmeter.protocol.http.control.CookieManager;
@@ -150,9 +150,11 @@ public class HTTPHC4Impl extends HTTPHCA
         public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
             long duration = super.getKeepAliveDuration(response, context);
             if (duration <= 0 && IDLE_TIMEOUT > 0) {// none found by the superclass
-                log.debug("Setting keepalive to " + IDLE_TIMEOUT);
+                if(log.isDebugEnabled()) {
+                    log.debug("Setting keepalive to " + IDLE_TIMEOUT);
+                }
                 return IDLE_TIMEOUT;
-            }
+            } 
             return duration; // return the super-class value
         }
         
@@ -290,6 +292,8 @@ public class HTTPHC4Impl extends HTTPHCA
             URI uri = url.toURI();
             if (method.equals(HTTPConstants.POST)) {
                 httpRequest = new HttpPost(uri);
+            } else if (method.equals(HTTPConstants.GET)) {
+                httpRequest = new HttpGet(uri);
             } else if (method.equals(HTTPConstants.PUT)) {
                 httpRequest = new HttpPut(uri);
             } else if (method.equals(HTTPConstants.HEAD)) {
@@ -300,8 +304,6 @@ public class HTTPHC4Impl extends HTTPHCA
                 httpRequest = new HttpOptions(uri);
             } else if (method.equals(HTTPConstants.DELETE)) {
                 httpRequest = new HttpDelete(uri);
-            } else if (method.equals(HTTPConstants.GET)) {
-                httpRequest = new HttpGet(uri);
             } else if (method.equals(HTTPConstants.PATCH)) {
                 httpRequest = new HttpPatch(uri);
             } else if (HttpWebdav.isWebdavMethod(method)) {
@@ -716,13 +718,14 @@ public class HTTPHC4Impl extends HTTPHCA
                 resolver = new SystemDefaultDnsResolver();
             }
             ClientConnectionManager connManager = new MeasuringConnectionManager(SchemeRegistryFactory.createDefault(),
resolver);
-
+            
             httpClient = new DefaultHttpClient(connManager, clientParams) {
                 @Override
                 protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                     return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false); // set
retry count
                 }
             };
+            
             if (IDLE_TIMEOUT > 0) {
                 ((AbstractHttpClient) httpClient).setKeepAliveStrategy(IDLE_STRATEGY );
             }
@@ -1409,7 +1412,8 @@ public class HTTPHC4Impl extends HTTPHCA
         if ( mapHttpClientPerHttpClientKey != null ) {
             for ( HttpClient cl : mapHttpClientPerHttpClientKey.values() ) {
                 ((AbstractHttpClient) cl).clearRequestInterceptors(); 
-                ((AbstractHttpClient) cl).clearResponseInterceptors(); 
+                ((AbstractHttpClient) cl).clearResponseInterceptors();
+                ((AbstractHttpClient) cl).close();
                 cl.getConnectionManager().shutdown();
             }
             mapHttpClientPerHttpClientKey.clear();



Mime
View raw message