Skip to content

Commit 8e6ca6a

Browse files
authored
Merge pull request quarkusio#46873 from gsmet/reduce-logging-allocations
Reduce debug logging allocations in MongoDnsClient
2 parents 6c767c5 + d85fa2a commit 8e6ca6a

File tree

1 file changed

+5
-3
lines changed
  • extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns

1 file changed

+5
-3
lines changed

extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public class MongoDnsClient implements DnsClient {
8383
}
8484
dnsClientOptions.setQueryTimeout(config.getValue(DNS_LOOKUP_TIMEOUT, Duration.class).toMillis());
8585

86-
log.debugf("DNS client options: %s", dnsClientOptions.toJson());
86+
if (log.isDebugEnabled()) {
87+
log.debugf("DNS client options: %s", dnsClientOptions.toJson());
88+
}
8789
dnsClient = mutinyVertx.createDnsClient(dnsClientOptions);
8890
}
8991

@@ -97,7 +99,7 @@ private static List<String> nameServers() {
9799
.map(line -> line.split(" ")[1])
98100
.collect(Collectors.toList());
99101
} catch (IOException | ArrayIndexOutOfBoundsException e) {
100-
Logger.getLogger(MongoDnsClientProvider.class).info("Unable to read the /etc/resolv.conf file", e);
102+
log.info("Unable to read the /etc/resolv.conf file", e);
101103
}
102104
}
103105
return nameServers;
@@ -164,7 +166,7 @@ public void accept(List<SrvRecord> srvRecords) {
164166
results.add(r);
165167
}
166168
hosts.addAll(results);
167-
log.debugf("Resolved SRV records for %s: %s", srvHost, String.join(", ", results));
169+
log.debugf("Resolved SRV records for %s: %s", srvHost, results);
168170
} catch (Throwable e) {
169171
throw new MongoConfigurationException("Unable to look up SRV record for host " + srvHost, e);
170172
}

0 commit comments

Comments
 (0)