Fix calls to logger's log(string)
This is in preparation for Google's PII efforts that are planned later.
Google-Bug-Id: b/209582622
Change-Id: Ife751a1bf38356906b24af07f51b902e100ff74d
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerSubmitRule.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerSubmitRule.java
index 4053413..32c0d58 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerSubmitRule.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerSubmitRule.java
@@ -99,9 +99,8 @@
}
} catch (RestApiException e) {
logger.atFine().withCause(e).log(
- String.format(
- "Couldn't evaluate code owner statuses for patch set %d of change %d.",
- changeData.currentPatchSet().id().get(), changeData.change().getId().get()));
+ "Couldn't evaluate code owner statuses for patch set %d of change %d.",
+ changeData.currentPatchSet().id().get(), changeData.change().getId().get());
return Optional.of(notReady());
} catch (Exception e) {
// Whether the exception should be treated as RULE_ERROR.
@@ -157,7 +156,7 @@
if (isRuleError) {
codeOwnerMetrics.countCodeOwnerSubmitRuleErrors.increment(cause);
- logger.atWarning().log(errorMessage);
+ logger.atWarning().log("%s", errorMessage);
return Optional.of(ruleError(errorMessage));
}
throw new CodeOwnersInternalServerErrorException(errorMessage, e);
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersOnAddReviewer.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersOnAddReviewer.java
index a694ce5..68a7672 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersOnAddReviewer.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersOnAddReviewer.java
@@ -167,9 +167,8 @@
.call();
} catch (Exception e) {
logger.atSevere().withCause(e).log(
- String.format(
- "Failed to post code-owners change message for reviewer on change %s in project %s.",
- changeId, projectName));
+ "Failed to post code-owners change message for reviewer on change %s in project %s.",
+ changeId, projectName);
}
}
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
index 05c9f0e..dbe3744 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java
@@ -220,7 +220,7 @@
SECTION_CODE_OWNERS,
branch,
KEY_BACKEND));
- logger.atSevere().log(e.getMessage());
+ logger.atSevere().log("%s", e.getMessage());
return e;
}));
}
@@ -252,7 +252,7 @@
"Code owner backend '%s' that is configured for project %s in"
+ " %s.config (parameter %s.%s) not found.",
backendName, project, pluginName, SECTION_CODE_OWNERS, KEY_BACKEND));
- logger.atSevere().log(e.getMessage());
+ logger.atSevere().log("%s", e.getMessage());
return e;
}));
}
@@ -269,7 +269,7 @@
"Code owner backend '%s' that is configured in gerrit.config"
+ " (parameter plugin.%s.%s) not found.",
defaultBackendName, pluginName, KEY_BACKEND));
- logger.atSevere().log(e.getMessage());
+ logger.atSevere().log("%s", e.getMessage());
return e;
});
}
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java b/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
index 97029e0..2353a31 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigValidator.java
@@ -106,7 +106,7 @@
receiveEvent.commit.getName(),
RefNames.REFS_CONFIG,
receiveEvent.project.getNameKey());
- logger.atSevere().withCause(e).log(errorMessage);
+ logger.atSevere().withCause(e).log("%s", errorMessage);
throw new CommitValidationException(errorMessage, e);
}
}
diff --git a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
index 136ffcb..07828b9 100644
--- a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
+++ b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
@@ -380,7 +380,7 @@
"skipping code owner config validation not allowed",
new CommitValidationMessage(e.getMessage(), ValidationMessage.Type.ERROR)));
} catch (SkipCodeOwnerConfigValidationPushOption.InvalidValueException e) {
- logger.atFine().log(e.getMessage());
+ logger.atFine().log("%s", e.getMessage());
return Optional.of(
ValidationResult.create(
pluginName,
@@ -445,10 +445,9 @@
// accept that it's possible to add invalid code owner configs while the plugin configuration
// is invalid.
logger.atWarning().log(
- String.format(
- "cannot validate code owner config files due to invalid code-owners plugin"
- + " configuration: %s",
- e.getMessage()));
+ "cannot validate code owner config files due to invalid code-owners plugin"
+ + " configuration: %s",
+ e.getMessage());
return Optional.of(
ValidationResult.create(
pluginName,
@@ -463,7 +462,6 @@
"failed to validate code owner config files in revision %s"
+ " (project = %s, branch = %s)",
revCommit.getName(), branchNameKey.project(), branchNameKey.branch());
- logger.atSevere().withCause(e).log(errorMessage);
throw new CodeOwnersInternalServerErrorException(errorMessage, e);
}
}