mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-27 07:55:25 +00:00
logging: use format specifiers instead of string concatenation
This commit is contained in:

committed by
Guillaume Nodet

parent
b0b7115344
commit
50653ae7d9
@@ -143,7 +143,7 @@ public class DaemonConnection implements AutoCloseable {
|
||||
if (failure == null) {
|
||||
failure = throwable;
|
||||
} else if (!Thread.currentThread().isInterrupted()) {
|
||||
LOGGER.error(String.format("Could not stop %s.", element), throwable);
|
||||
LOGGER.error("Could not stop {}.", element, throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -293,10 +293,9 @@ public class DaemonRegistry implements AutoCloseable {
|
||||
} catch (IllegalStateException | ArrayIndexOutOfBoundsException | BufferUnderflowException e) {
|
||||
String absPath = registryFile.toAbsolutePath().normalize().toString();
|
||||
LOGGER.warn(
|
||||
"Invalid daemon registry info, " + "trying to recover from this issue. "
|
||||
+ "If you keep getting this warning, "
|
||||
+ "try deleting the `registry.bin` file at ["
|
||||
+ absPath + "]",
|
||||
"Invalid daemon registry info, trying to recover from this issue. "
|
||||
+ "If you keep getting this warning, try deleting the `registry.bin` file at [{}]",
|
||||
absPath,
|
||||
e);
|
||||
this.reset();
|
||||
return;
|
||||
@@ -337,7 +336,7 @@ public class DaemonRegistry implements AutoCloseable {
|
||||
try {
|
||||
return Integer.parseInt(pid);
|
||||
} catch (NumberFormatException x) {
|
||||
LOGGER.warn("Unable to determine PID from malformed /proc/self link `" + pid + "`");
|
||||
LOGGER.warn("Unable to determine PID from malformed /proc/self link `{}`", pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,8 +351,7 @@ public class DaemonRegistry implements AutoCloseable {
|
||||
return Integer.parseInt(pid);
|
||||
} catch (NumberFormatException x) {
|
||||
int rpid = new Random().nextInt(1 << 16);
|
||||
LOGGER.warn(
|
||||
"Unable to determine PID from malformed VM name `" + vmname + "`, picked a random number=" + rpid);
|
||||
LOGGER.warn("Unable to determine PID from malformed VM name `{}`, picked a random number={}", vmname, rpid);
|
||||
return rpid;
|
||||
}
|
||||
}
|
||||
|
@@ -78,13 +78,15 @@ public class OsUtils {
|
||||
return Long.parseLong(output.get(0).trim());
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.warn(
|
||||
"Could not parse the output of " + Stream.of(cmd).collect(Collectors.joining(" "))
|
||||
+ " as a long:\n"
|
||||
+ output.stream().collect(Collectors.joining("\n")));
|
||||
"Could not parse the output of {} as a long:\n{}",
|
||||
Stream.of(cmd).collect(Collectors.joining(" ")),
|
||||
output.stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Unexpected output of " + Stream.of(cmd).collect(Collectors.joining(" ")) + ":\n"
|
||||
+ output.stream().collect(Collectors.joining("\n")));
|
||||
LOGGER.warn(
|
||||
"Unexpected output of {}:\n{}",
|
||||
Stream.of(cmd).collect(Collectors.joining(" ")),
|
||||
output.stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
return -1;
|
||||
} else if (os == Os.WINDOWS) {
|
||||
@@ -97,14 +99,16 @@ public class OsUtils {
|
||||
try {
|
||||
return Long.parseLong(nonEmptyLines.get(1).trim()) / KB;
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.warn("Could not parse the second line of "
|
||||
+ Stream.of(cmd).collect(Collectors.joining(" "))
|
||||
+ " output as a long:\n"
|
||||
+ nonEmptyLines.stream().collect(Collectors.joining("\n")));
|
||||
LOGGER.warn(
|
||||
"Could not parse the second line of {} output as a long:\n{}",
|
||||
Stream.of(cmd).collect(Collectors.joining(" ")),
|
||||
nonEmptyLines.stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Unexpected output of " + Stream.of(cmd).collect(Collectors.joining(" ")) + ":\n"
|
||||
+ output.stream().collect(Collectors.joining("\n")));
|
||||
LOGGER.warn(
|
||||
"Unexpected output of {}:\n{}",
|
||||
Stream.of(cmd).collect(Collectors.joining(" ")),
|
||||
output.stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
@@ -136,11 +140,14 @@ public class OsUtils {
|
||||
try (CommandProcess ps = new CommandProcess(builder.start(), output::add)) {
|
||||
final int exitCode = ps.waitFor(1000);
|
||||
if (exitCode != 0) {
|
||||
LOGGER.warn(Stream.of(cmd).collect(Collectors.joining(" ")) + " exited with " + exitCode + ":\n"
|
||||
+ output.stream().collect(Collectors.joining("\n")));
|
||||
LOGGER.warn(
|
||||
"{} exited with {}:\n{}",
|
||||
Stream.of(cmd).collect(Collectors.joining(" ")),
|
||||
exitCode,
|
||||
output.stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Could not execute " + Stream.of(cmd).collect(Collectors.joining(" ")));
|
||||
LOGGER.warn("Could not execute {}", Stream.of(cmd).collect(Collectors.joining(" ")));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
Reference in New Issue
Block a user