Use Logger's built-in String formatting
Change-Id: I6908ae6f92092280566dcf6e7d2bc1e85c5c35c4
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
index 81dbcd8..e27697a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
@@ -19,7 +19,6 @@
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
-import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
@@ -168,14 +167,17 @@
private void logNotRateUnit(String section, String subsection, String name, String valueString) {
if (subsection != null) {
log.error(
- MessageFormat.format(
- "Invalid rate unit value: {0}.{1}.{2}={3}; ignoring the configuration entry",
- section, subsection, name, valueString));
+ "Invalid rate unit value: {}.{}.{}={}; ignoring the configuration entry",
+ section,
+ subsection,
+ name,
+ valueString);
} else {
log.error(
- MessageFormat.format(
- "Invalid rate unit value: {0}.{1}={2}; ignoring the configuration entry",
- section, name, valueString));
+ "Invalid rate unit value: {}.{}={}; ignoring the configuration entry",
+ section,
+ name,
+ valueString);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/MaxRepositorySizeQuota.java b/src/main/java/com/googlesource/gerrit/plugins/quota/MaxRepositorySizeQuota.java
index 5e923ad..f01255a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/MaxRepositorySizeQuota.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/MaxRepositorySizeQuota.java
@@ -118,7 +118,7 @@
long maxPackSize = Ordering.<Long>natural().nullsLast().min(maxPackSize1, maxPackSize2);
rp.setMaxPackSizeLimit(maxPackSize);
} catch (ExecutionException e) {
- log.warn("Couldn't setMaxPackSizeLimit on receive-pack for " + project.get(), e);
+ log.warn("Couldn't setMaxPackSizeLimit on receive-pack for {}", project, e);
}
}
@@ -129,7 +129,7 @@
try {
cache.get(project).getAndAdd(rp.getPackSize());
} catch (ExecutionException e) {
- log.warn("Couldn't process onPostReceive for " + project.get(), e);
+ log.warn("Couldn't process onPostReceive for {}", project, e);
}
}
}
@@ -210,7 +210,7 @@
try {
cache.get(p).set(size);
} catch (ExecutionException e) {
- log.warn("Error setting the size of project " + p.get(), e);
+ log.warn("Error setting the size of project {}", p, e);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/ProjectNameResolver.java b/src/main/java/com/googlesource/gerrit/plugins/quota/ProjectNameResolver.java
index 038a201..bf3ece6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/ProjectNameResolver.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/ProjectNameResolver.java
@@ -43,7 +43,7 @@
String n = p.substring(0, p.length() - ".git".length());
return new Project.NameKey(n);
}
- log.warn("Couldn't determine the project name from " + gitDir);
+ log.warn("Couldn't determine the project name from {}", gitDir);
return null;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/Publisher.java b/src/main/java/com/googlesource/gerrit/plugins/quota/Publisher.java
index 319c2eb..b7a43db 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/Publisher.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/Publisher.java
@@ -52,7 +52,7 @@
events.add(creator.create());
} catch (RuntimeException e) {
String creatorName = creator.getName();
- log.warn("Exception in usage data event creator " + creatorName, e);
+ log.warn("Exception in usage data event creator {}", creatorName, e);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListener.java b/src/main/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListener.java
index 0b36ebb..dfac1d9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListener.java
@@ -132,17 +132,14 @@
try {
limiter = limitsPerAccount.get(accountId).get();
} catch (ExecutionException e) {
- String msg = MessageFormat.format("Cannot get rate limits for account ''{0}''", accountId);
- log.warn(msg, e);
+ log.warn("Cannot get rate limits for account ''{}''", accountId, e);
}
} else {
try {
limiter = limitsPerRemoteHost.get(remoteHost).get();
} catch (ExecutionException e) {
- String msg =
- MessageFormat.format(
- "Cannot get rate limits for anonymous access from remote host ''{0}''", remoteHost);
- log.warn(msg, e);
+ log.warn(
+ "Cannot get rate limits for anonymous access from remote host ''{}''", remoteHost, e);
}
}
if (limiter != null && !limiter.tryAcquire()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java b/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
index eb9c493..ca59d8d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiter.java
@@ -80,20 +80,17 @@
rateLimiterHolder = limitsPerAccount.get(accountId);
} catch (ExecutionException e) {
rateLimiterHolder = Holder.EMPTY;
- String msg =
- MessageFormat.format("Cannot get rate limits for account ''{0}''", accountId);
- log.warn(msg, e);
+ log.warn("Cannot get rate limits for account ''{}''", accountId, e);
}
} else {
try {
rateLimiterHolder = limitsPerRemoteHost.get(req.getRemoteHost());
} catch (ExecutionException e) {
rateLimiterHolder = Holder.EMPTY;
- String msg =
- MessageFormat.format(
- "Cannot get rate limits for anonymous access from remote host ''{0}''",
- req.getRemoteHost());
- log.warn(msg, e);
+ log.warn(
+ "Cannot get rate limits for anonymous access from remote host ''{}''",
+ req.getRemoteHost(),
+ e);
}
}
if (!rateLimiterHolder.hasGracePermits()