You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2017/07/30 19:55:57 UTC

Re: svn commit: r1803103 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java

On 26 July 2017 at 20:56,  <fs...@apache.org> wrote:
> Author: fschumacher
> Date: Wed Jul 26 19:56:08 2017
> New Revision: 1803103
>
> URL: http://svn.apache.org/viewvc?rev=1803103&view=rev
> Log:
> Guard debug log messages that call a function with Logger#isDebugEnabled
>
> Bugzilla Id: 61176
>
> Modified:
>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1803103&r1=1803102&r2=1803103&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java (original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java Wed Jul 26 19:56:08 2017
> @@ -498,8 +498,10 @@ public class CacheManager extends Config
>
>      private CacheEntry getEntry(String url, Header[] headers) {
>          CacheEntry entry = getCache().get(url);

Fetch the cache separately here - see below.

> -        log.debug("Cache: {}", getCache());
> -        log.debug("inCache {} {} {}", url, entry, headers);
> +        if (log.isDebugEnabled()) {
> +            log.debug("Cache: {}", getCache());

In this case, it would be better to fetch the cache once and store in
a local variable.

> +            log.debug("inCache {} {} {}", url, entry, headers);
> +        }
>          if (entry == null) {
>              log.debug("No entry found for url {}", url);
>              return null;
> @@ -509,12 +511,16 @@ public class CacheManager extends Config
>              return entry;
>          }
>          if (headers == null) {
> -            log.debug("Entry {} found, but it should depend on vary {} for url {}", entry, entry.getVaryHeader(), url);
> +            if (log.isDebugEnabled()) {
> +                log.debug("Entry {} found, but it should depend on vary {} for url {}", entry, entry.getVaryHeader(), url);
> +            }
>              return null;
>          }
>          Pair<String, String> varyPair = getVaryHeader(entry.getVaryHeader(), headers);
>          if (varyPair != null) {
> -            log.debug("Looking again for {} because of {} with vary: {} ({})", url, entry, entry.getVaryHeader(), varyPair);
> +            if (log.isDebugEnabled()) {
> +                log.debug("Looking again for {} because of {} with vary: {} ({})", url, entry, entry.getVaryHeader(), varyPair);
> +            }
>              return getEntry(varyUrl(url, entry.getVaryHeader(), varyPair.getRight()), null);
>          }
>          return null;
>
>

Re: svn commit: r1803103 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java

Posted by Felix Schumacher <fe...@internetallee.de>.

Am 30. Juli 2017 21:55:57 MESZ schrieb sebb <se...@gmail.com>:
>On 26 July 2017 at 20:56,  <fs...@apache.org> wrote:
>> Author: fschumacher
>> Date: Wed Jul 26 19:56:08 2017
>> New Revision: 1803103
>>
>> URL: http://svn.apache.org/viewvc?rev=1803103&view=rev
>> Log:
>> Guard debug log messages that call a function with
>Logger#isDebugEnabled
>>
>> Bugzilla Id: 61176
>>
>> Modified:
>>    
>jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>>
>> Modified:
>jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>> URL:
>http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1803103&r1=1803102&r2=1803103&view=diff
>>
>==============================================================================
>> ---
>jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>(original)
>> +++
>jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
>Wed Jul 26 19:56:08 2017
>> @@ -498,8 +498,10 @@ public class CacheManager extends Config
>>
>>      private CacheEntry getEntry(String url, Header[] headers) {
>>          CacheEntry entry = getCache().get(url);
>
>Fetch the cache separately here - see below.
>
>> -        log.debug("Cache: {}", getCache());
>> -        log.debug("inCache {} {} {}", url, entry, headers);
>> +        if (log.isDebugEnabled()) {
>> +            log.debug("Cache: {}", getCache());
>
>In this case, it would be better to fetch the cache once and store in
>a local variable.

Right. I was probably not thinking clearly enough in that moment. My intention was to not log the cache at all.

Felix

>
>> +            log.debug("inCache {} {} {}", url, entry, headers);
>> +        }
>>          if (entry == null) {
>>              log.debug("No entry found for url {}", url);
>>              return null;
>> @@ -509,12 +511,16 @@ public class CacheManager extends Config
>>              return entry;
>>          }
>>          if (headers == null) {
>> -            log.debug("Entry {} found, but it should depend on vary
>{} for url {}", entry, entry.getVaryHeader(), url);
>> +            if (log.isDebugEnabled()) {
>> +                log.debug("Entry {} found, but it should depend on
>vary {} for url {}", entry, entry.getVaryHeader(), url);
>> +            }
>>              return null;
>>          }
>>          Pair<String, String> varyPair =
>getVaryHeader(entry.getVaryHeader(), headers);
>>          if (varyPair != null) {
>> -            log.debug("Looking again for {} because of {} with vary:
>{} ({})", url, entry, entry.getVaryHeader(), varyPair);
>> +            if (log.isDebugEnabled()) {
>> +                log.debug("Looking again for {} because of {} with
>vary: {} ({})", url, entry, entry.getVaryHeader(), varyPair);
>> +            }
>>              return getEntry(varyUrl(url, entry.getVaryHeader(),
>varyPair.getRight()), null);
>>          }
>>          return null;
>>
>>