Fix Flogger issues flagged by error prone
Release-Notes: skip
Change-Id: Ia6eb940e03cf8e8ac2696ca45a52ef144cee5de4
diff --git a/java/com/google/gerrit/httpd/init/WebAppInitializer.java b/java/com/google/gerrit/httpd/init/WebAppInitializer.java
index 68cf1b2..dbda12a 100644
--- a/java/com/google/gerrit/httpd/init/WebAppInitializer.java
+++ b/java/com/google/gerrit/httpd/init/WebAppInitializer.java
@@ -210,7 +210,7 @@
buf.append("\nResolve above errors before continuing.");
buf.append("\nComplete stack trace follows:");
}
- logger.atSevere().withCause(first.getCause()).log(buf.toString());
+ logger.atSevere().withCause(first.getCause()).log("%s", buf);
throw new CreationException(Collections.singleton(first));
}
diff --git a/java/com/google/gerrit/sshd/BaseCommand.java b/java/com/google/gerrit/sshd/BaseCommand.java
index b4404a1..547aff3 100644
--- a/java/com/google/gerrit/sshd/BaseCommand.java
+++ b/java/com/google/gerrit/sshd/BaseCommand.java
@@ -399,7 +399,7 @@
isZeroLength = Arrays.stream(stackTrace).anyMatch(s -> s.toString().contains(zeroLength));
}
if (!isZeroLength) {
- logger.atSevere().withCause(e).log(message.toString());
+ logger.atSevere().withCause(e).log("%s", message);
}
}
diff --git a/java/com/google/gerrit/sshd/SshDaemon.java b/java/com/google/gerrit/sshd/SshDaemon.java
index f9d0769..cc35a32 100644
--- a/java/com/google/gerrit/sshd/SshDaemon.java
+++ b/java/com/google/gerrit/sshd/SshDaemon.java
@@ -643,7 +643,7 @@
msg.append(avail[i].getName());
}
msg.append(" is supported");
- logger.atSevere().log(msg.toString());
+ logger.atSevere().log("%s", msg);
} else if (add) {
if (!def.contains(n)) {
def.add(n);
diff --git a/java/com/google/gerrit/sshd/commands/Receive.java b/java/com/google/gerrit/sshd/commands/Receive.java
index 92666f3..3f2e2ad 100644
--- a/java/com/google/gerrit/sshd/commands/Receive.java
+++ b/java/com/google/gerrit/sshd/commands/Receive.java
@@ -110,7 +110,7 @@
msg.append(currentUser.getAccountId());
msg.append("): ");
msg.append(badStream.getCause().getMessage());
- logger.atInfo().log(msg.toString());
+ logger.atInfo().log("%s", msg);
throw new UnloggedFailure(128, "error: " + badStream.getCause().getMessage());
}
StringBuilder msg = new StringBuilder();
diff --git a/javatests/com/google/gerrit/acceptance/ssh/SshCommandsIT.java b/javatests/com/google/gerrit/acceptance/ssh/SshCommandsIT.java
index 469630f..ac05801 100644
--- a/javatests/com/google/gerrit/acceptance/ssh/SshCommandsIT.java
+++ b/javatests/com/google/gerrit/acceptance/ssh/SshCommandsIT.java
@@ -144,7 +144,7 @@
// option causes the usage info to be written to stderr. Instead, we assert on the
// content of the stderr, which will always start with "gerrit command" when the --help
// option is used.
- logger.atFine().log(cmd);
+ logger.atFine().log("%s", cmd);
adminSshSession.exec(String.format("%s --help", cmd));
String response = adminSshSession.getError();
assertWithMessage(String.format("command %s failed: %s", cmd, response))