You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2020/09/26 18:14:54 UTC
[jmeter] branch master updated: Move guard clause for log message
generation
This is an automated email from the ASF dual-hosted git repository.
fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new 1368555 Move guard clause for log message generation
1368555 is described below
commit 13685551442e3a7806514d2fa81b7c3b0e1fbe32
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sat Sep 26 14:16:54 2020 +0200
Move guard clause for log message generation
The guard clause is not visible for sonaqube and we
can silence a warning by this move. Another reason
for the move is, that we save a few lines of code.
---
.../protocol/http/control/DNSCacheManager.java | 24 ++++++++--------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/control/DNSCacheManager.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
index c2d9a95..be4be22 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
@@ -148,32 +148,26 @@ public class DNSCacheManager extends ConfigTestElement implements TestIterationL
// explicitly maps the key to null
// https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html
if (result != null || cache.containsKey(host)) {
- if (log.isDebugEnabled()) {
- logCache("hit", host, result);
- }
+ logCache("hit", host, result);
return result;
} else if (isStaticHost(host)) {
InetAddress[] staticAddresses = fromStaticHost(host);
- if (log.isDebugEnabled()) {
- logCache("miss", host, staticAddresses);
- }
+ logCache("miss", host, staticAddresses);
cache.put(host, staticAddresses);
return staticAddresses;
} else {
InetAddress[] addresses = requestLookup(host);
- if (log.isDebugEnabled()) {
- logCache("miss", host, addresses);
- }
+ logCache("miss", host, addresses);
cache.put(host, addresses);
return addresses;
}
}
private void logCache(String hitOrMiss, String host, InetAddress[] addresses) {
- log.debug("Cache {} thread#{}: {} => {}", hitOrMiss,
- JMeterContextService.getContext().getThreadNum(),
- host,
- Arrays.toString(addresses));
+ if (log.isDebugEnabled()) {
+ log.debug("Cache {} thread#{}: {} => {}", hitOrMiss, JMeterContextService.getContext().getThreadNum(), host,
+ Arrays.toString(addresses));
+ }
}
private boolean isStaticHost(String host) {
@@ -259,9 +253,7 @@ public class DNSCacheManager extends ConfigTestElement implements TestIterationL
}
} else {
addresses = systemDefaultDnsResolver.resolve(host);
- if (log.isDebugEnabled()) {
- logCache("miss (resolved with system resolver)", host, addresses);
- }
+ logCache("miss (resolved with system resolver)", host, addresses);
}
return addresses;