You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/03/08 12:28:38 UTC

svn commit: r1785952 - in /jmeter/trunk/src: core/org/apache/jmeter/engine/ protocol/http/org/apache/jmeter/protocol/http/gui/ protocol/http/org/apache/jmeter/protocol/http/sampler/ protocol/http/org/apache/jmeter/protocol/http/sampler/hc/

Author: pmouawad
Date: Wed Mar  8 12:28:37 2017
New Revision: 1785952

URL: http://svn.apache.org/viewvc?rev=1785952&view=rev
Log:
Misc logging improvements
Contributed by Benoit Wiart 
This closes #281

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/engine/ClientJMeterEngine.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/JMeterPoolingClientConnectionManager.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/engine/ClientJMeterEngine.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/ClientJMeterEngine.java?rev=1785952&r1=1785951&r2=1785952&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/ClientJMeterEngine.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/ClientJMeterEngine.java Wed Mar  8 12:28:37 2017
@@ -167,7 +167,7 @@ public class ClientJMeterEngine implemen
         for(Thread t : Thread.getAllStackTraces().keySet()){
             String name = t.getName();
             if (name.matches(reaperRE)) {
-                logger.info("Interrupting "+name);
+                logger.info("Interrupting {}", name);
                 t.interrupt();
             }
         }
@@ -177,7 +177,7 @@ public class ClientJMeterEngine implemen
     // Called by JMeter ListenToTest if remoteStop is true
     @Override
     public void exit() {
-        log.info("about to exit remote server on "+host);
+        log.info("about to exit remote server on {}", host);
         try {
             remote.rexit();
         } catch (RemoteException e) {
@@ -186,6 +186,7 @@ public class ClientJMeterEngine implemen
     }
 
     private Properties savep;
+    
     /** {@inheritDoc} */
     @Override
     public void setProperties(Properties p) {

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java?rev=1785952&r1=1785951&r2=1785952&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java Wed Mar  8 12:28:37 2017
@@ -393,7 +393,7 @@ public class AuthPanel extends AbstractC
         @Override
         public void setValueAt(Object value, int row, int column) {
             Authorization auth = manager.getAuthObjectAt(row);
-            log.debug("Setting auth value: " + value);
+            log.debug("Setting auth value: {}", value);
             switch (column){
                 case AuthManager.COL_URL:
                     auth.setURL((String) value);

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=1785952&r1=1785951&r2=1785952&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 Wed Mar  8 12:28:37 2017
@@ -172,9 +172,7 @@ 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
-                if(log.isDebugEnabled()) {
-                    log.debug("Setting keepalive to " + IDLE_TIMEOUT);
-                }
+                log.debug("Setting keepalive to {}", IDLE_TIMEOUT);
                 return IDLE_TIMEOUT;
             } 
             return duration; // return the super-class value
@@ -271,7 +269,7 @@ public class HTTPHC4Impl extends HTTPHCA
     private static final String HTTPCLIENT_TOKEN = "__jmeter.HTTPCLIENT_TOKEN__";
 
     static {
-        log.info("HTTP request retry count = "+RETRY_COUNT);
+        log.info("HTTP request retry count = {}", RETRY_COUNT);
 
         DEFAULT_HTTP_PARAMS = new SyncBasicHttpParams(); // Could we drop the Sync here?
         DEFAULT_HTTP_PARAMS.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
@@ -286,7 +284,7 @@ public class HTTPHC4Impl extends HTTPHCA
 
         // Set up HTTP scheme override if necessary
         if (CPS_HTTP > 0) {
-            log.info("Setting up HTTP SlowProtocol, cps="+CPS_HTTP);
+            log.info("Setting up HTTP SlowProtocol, cps={}", CPS_HTTP);
             SLOW_HTTP = new Scheme(HTTPConstants.PROTOCOL_HTTP, HTTPConstants.DEFAULT_HTTP_PORT, new SlowHC4SocketFactory(CPS_HTTP));
         } else {
             SLOW_HTTP = null;
@@ -340,8 +338,8 @@ public class HTTPHC4Impl extends HTTPHCA
             boolean areFollowingRedirect, int frameDepth) {
 
         if (log.isDebugEnabled()) {
-            log.debug("Start : sample " + url.toString());
-            log.debug("method " + method+ " followingRedirect " + areFollowingRedirect + " depth " + frameDepth);            
+            log.debug("Start : sample {} method {} followingRedirect {} depth {}", 
+                    url, method, areFollowingRedirect, frameDepth);            
         }
 
         HTTPSampleResult res = createSampleResult(url, method);
@@ -461,16 +459,16 @@ public class HTTPHC4Impl extends HTTPHCA
             res.setBodySize(totalBytes - headerBytes);
             res.setSentBytes(metrics.getSentBytesCount());
             if (log.isDebugEnabled()) {
-                log.debug("ResponseHeadersSize=" + res.getHeadersSize() + " Content-Length=" + res.getBodySizeAsLong()
-                        + " Total=" + (res.getHeadersSize() + res.getBodySizeAsLong()));
+                log.debug("ResponseHeadersSize={} Content-Length={} Total={}",
+                        res.getHeadersSize(), res.getBodySizeAsLong(), (res.getHeadersSize() + res.getBodySizeAsLong()));
             }
 
             // If we redirected automatically, the URL may have changed
-            if (getAutoRedirects()){
+            if (getAutoRedirects()) {
                 HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(HttpCoreContext.HTTP_REQUEST);
                 HttpHost target = (HttpHost) localContext.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
                 URI redirectURI = req.getURI();
-                if (redirectURI.isAbsolute()){
+                if (redirectURI.isAbsolute()) {
                     res.setURL(redirectURI.toURL());
                 } else {
                     res.setURL(new URL(new URL(target.toURI()),redirectURI.toString()));
@@ -495,7 +493,7 @@ public class HTTPHC4Impl extends HTTPHCA
             }
            // pick up headers if failed to execute the request
             if (res.getRequestHeaders() != null) {
-                log.debug("Overwriting request old headers: " + res.getRequestHeaders());
+                log.debug("Overwriting request old headers: {}", res.getRequestHeaders());
             }
             res.setRequestHeaders(getConnectionHeaders((HttpRequest) localContext.getAttribute(HttpCoreContext.HTTP_REQUEST)));
             errorResult(e, res);
@@ -522,9 +520,7 @@ public class HTTPHC4Impl extends HTTPHCA
     private void extractClientContextAfterSample(HttpContext localContext) {
         Object userToken = localContext.getAttribute(HttpClientContext.USER_TOKEN);
         if(userToken != null) {
-            if(log.isDebugEnabled()) {
-                log.debug("Extracted from HttpContext user token:"+userToken+", storing it as JMeter variable:"+USER_TOKEN);
-            }
+            log.debug("Extracted from HttpContext user token:{} storing it as JMeter variable:{}", userToken, USER_TOKEN);
             // During recording JMeterContextService.getContext().getVariables() is null
             JMeterVariables jMeterVariables = JMeterContextService.getContext().getVariables();
             if (jMeterVariables != null) {
@@ -546,18 +542,14 @@ public class HTTPHC4Impl extends HTTPHCA
             userToken = jMeterVariables.getObject(USER_TOKEN);            
         }
         if(userToken != null) {
-            if(log.isDebugEnabled()) {
-                log.debug("Found user token:"+userToken+" as JMeter variable:"+USER_TOKEN+", storing it in HttpContext");
-            }
+            log.debug("Found user token:{} as JMeter variable:{}, storing it in HttpContext", userToken, USER_TOKEN);
             localContext.setAttribute(HttpClientContext.USER_TOKEN, userToken);
         } else {
             // It would be better to create a ClientSessionManager that would compute this value
             // for now it can be Thread.currentThread().getName() but must be changed when we would change 
             // the Thread per User model
             String userId = Thread.currentThread().getName();
-            if(log.isDebugEnabled()) {
-                log.debug("Storing in HttpContext the user token:"+userId);
-            }
+            log.debug("Storing in HttpContext the user token: {}", userId);
             localContext.setAttribute(HttpClientContext.USER_TOKEN, userId);
         }
     }
@@ -632,7 +624,7 @@ public class HTTPHC4Impl extends HTTPHCA
                             (PrivilegedExceptionAction<HttpResponse>) () ->
                                     httpClient.execute(httpRequest, localContext));
                 } catch (PrivilegedActionException e) {
-                    log.error("Can't execute httpRequest with subject:" + subject, e);
+                    log.error("Can't execute httpRequest with subject: {}", subject, e);
                     throw new RuntimeException("Can't execute httpRequest with subject:" + subject, e);
                 }
             }
@@ -1209,10 +1201,8 @@ public class HTTPHC4Impl extends HTTPHCA
             }
             
             if(log.isDebugEnabled()) {
-                log.debug("Building multipart with:getDoBrowserCompatibleMultipart():"+
-                        getDoBrowserCompatibleMultipart()+
-                        ", with charset:"+charset+
-                        ", haveContentEncoding:"+haveContentEncoding);
+                log.debug("Building multipart with:getDoBrowserCompatibleMultipart(): {}, with charset:{}, haveContentEncoding:{}", 
+                        getDoBrowserCompatibleMultipart(), charset, haveContentEncoding);
             }
             // Write the request to our own stream
             MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create()

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java?rev=1785952&r1=1785951&r2=1785952&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHCAbstractImpl.java Wed Mar  8 12:28:37 2017
@@ -87,11 +87,11 @@ public abstract class HTTPHCAbstractImpl
             log.warn("You're using property 'httpclient.timeout' that will soon be deprecated for HttpClient3.1, you should either set "
                     + "timeout in HTTP Request GUI, HTTP Request Defaults or set http.socket.timeout in httpclient.parameters");
         }
-        if (NONPROXY_HOSTS.length() > 0){
+        if (NONPROXY_HOSTS.length() > 0) {
             StringTokenizer s = new StringTokenizer(NONPROXY_HOSTS,"|");// $NON-NLS-1$
-            while (s.hasMoreTokens()){
+            while (s.hasMoreTokens()) {
                 String t = s.nextToken();
-                if (t.indexOf('*') ==0){// e.g. *.apache.org // $NON-NLS-1$
+                if (t.indexOf('*') ==0) {// e.g. *.apache.org // $NON-NLS-1$
                     nonProxyHostSuffix.add(t.substring(1));
                 } else {
                     nonProxyHostFull.add(t);// e.g. www.apache.org
@@ -100,13 +100,13 @@ public abstract class HTTPHCAbstractImpl
         }
         NON_PROXY_HOST_SUFFIX_SIZE=nonProxyHostSuffix.size();
 
-        InetAddress inet=null;
+        InetAddress inet = null;
         String localHostOrIP =
             JMeterUtils.getPropDefault("httpclient.localaddress",""); // $NON-NLS-1$
-        if (localHostOrIP.length() > 0){
+        if (localHostOrIP.length() > 0) {
             try {
                 inet = InetAddress.getByName(localHostOrIP);
-                log.info("Using localAddress "+inet.getHostAddress());
+                log.info("Using localAddress {}", inet.getHostAddress());
             } catch (UnknownHostException e) {
                 log.warn(e.getLocalizedMessage());
             }
@@ -116,8 +116,7 @@ public abstract class HTTPHCAbstractImpl
         }
         localAddress = inet;
         LOCALHOST = localHostOrIP;
-        log.info("Local host = "+LOCALHOST);
-
+        log.info("Local host = {}", LOCALHOST);
     }
 
     protected HTTPHCAbstractImpl(HTTPSamplerBase testElement) {

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java?rev=1785952&r1=1785951&r2=1785952&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/ResourcesDownloader.java Wed Mar  8 12:28:37 2017
@@ -89,7 +89,7 @@ public class ResourcesDownloader {
     
     
     private void init() {
-        LOG.info("Creating ResourcesDownloader with keepalive_inseconds:"+THREAD_KEEP_ALIVE_TIME);
+        LOG.info("Creating ResourcesDownloader with keepalive_inseconds : {}", THREAD_KEEP_ALIVE_TIME);
         concurrentExecutor = new ThreadPoolExecutor(
                 MIN_POOL_SIZE, MAX_POOL_SIZE, THREAD_KEEP_ALIVE_TIME, TimeUnit.SECONDS,
                 new SynchronousQueue<>(),
@@ -114,7 +114,7 @@ public class ResourcesDownloader {
             List<Runnable> drainList = new ArrayList<>();
             concurrentExecutor.getQueue().drainTo(drainList);
             if(!drainList.isEmpty()) {
-                LOG.warn("the pool executor workqueue is not empty size=" + drainList.size());
+                LOG.warn("the pool executor workqueue is not empty size={}", drainList.size());
                 for (Runnable runnable : drainList) {
                     if(runnable instanceof Future<?>) {
                         Future<?> f = (Future<?>) runnable;
@@ -157,7 +157,7 @@ public class ResourcesDownloader {
         concurrentExecutor.setMaximumPoolSize(MAX_POOL_SIZE);
         
         if(LOG.isDebugEnabled()) {
-            LOG.debug("PoolSize=" + concurrentExecutor.getPoolSize()+" LargestPoolSize=" + concurrentExecutor.getLargestPoolSize());
+            LOG.debug("PoolSize={} LargestPoolSize={}", concurrentExecutor.getPoolSize(), concurrentExecutor.getLargestPoolSize());
         }
         
         CompletionService<AsynSamplerResultHolder> completionService = new ExecutorCompletionService<>(concurrentExecutor);
@@ -190,9 +190,7 @@ public class ResourcesDownloader {
         finally {
             //bug 51925 : Calling Stop on Test leaks executor threads when concurrent download of resources is on
             if(remainingTasksToTake > 0) {
-                if(LOG.isDebugEnabled()) {
-                    LOG.debug("Interrupted while waiting for resource downloads : cancelling remaining tasks");
-                }
+                LOG.debug("Interrupted while waiting for resource downloads : cancelling remaining tasks");
                 for (Future<AsynSamplerResultHolder> future : submittedTasks) {
                     if(!future.isDone()) {
                         future.cancel(true);

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/JMeterPoolingClientConnectionManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/JMeterPoolingClientConnectionManager.java?rev=1785952&r1=1785951&r2=1785952&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/JMeterPoolingClientConnectionManager.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/JMeterPoolingClientConnectionManager.java Wed Mar  8 12:28:37 2017
@@ -312,9 +312,7 @@ public class JMeterPoolingClientConnecti
     }
     @Override
     public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
-        if (this.log.isDebugEnabled()) {
-            this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
-        }
+        this.log.debug("Closing connections idle longer than {} {}", idleTimeout, tunit);
         this.pool.closeIdle(idleTimeout, tunit);
     }
     @Override