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

committed by
Guillaume Nodet

parent
b0b7115344
commit
50653ae7d9
@@ -498,7 +498,7 @@ public class DaemonConnector {
|
||||
sc.next();
|
||||
sc.next();
|
||||
String version = sc.next();
|
||||
LOGGER.warn("JAVA VERSION: " + version);
|
||||
LOGGER.warn("JAVA VERSION: {}", version);
|
||||
int is = version.charAt(0) == '"' ? 1 : 0;
|
||||
int ie = version.indexOf('.', version.indexOf('.', is));
|
||||
return Float.parseFloat(version.substring(is, ie));
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -389,7 +389,7 @@ public class Server implements AutoCloseable, Runnable {
|
||||
private void requestStop(String reason) {
|
||||
DaemonState state = getState();
|
||||
if (!(state == StopRequested || state == Stopped)) {
|
||||
LOGGER.info("Daemon will be stopped at the end of the build " + reason);
|
||||
LOGGER.info("Daemon will be stopped at the end of the build {}", reason);
|
||||
stateLock.lock();
|
||||
try {
|
||||
if (state == Busy) {
|
||||
@@ -405,7 +405,7 @@ public class Server implements AutoCloseable, Runnable {
|
||||
}
|
||||
|
||||
private void requestForcefulStop(String reason) {
|
||||
LOGGER.info("Daemon is stopping immediately " + reason);
|
||||
LOGGER.info("Daemon is stopping immediately {}", reason);
|
||||
stopNow(reason);
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ public class Server implements AutoCloseable, Runnable {
|
||||
LOGGER.info("No more message to dispatch");
|
||||
return;
|
||||
}
|
||||
LOGGER.info("Dispatch message: " + m);
|
||||
LOGGER.info("Dispatch message: {}", m);
|
||||
connection.dispatch(m);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
@@ -637,7 +637,7 @@ public class Server implements AutoCloseable, Runnable {
|
||||
|
||||
private void updateState(DaemonState state) {
|
||||
if (getState() != state) {
|
||||
LOGGER.info("Updating state to: " + state);
|
||||
LOGGER.info("Updating state to: {}", state);
|
||||
stateLock.lock();
|
||||
try {
|
||||
registry.store(info = info.withState(state));
|
||||
|
@@ -154,7 +154,7 @@ public class DaemonPrompter extends AbstractInputHandler implements Prompter, In
|
||||
Connection con = Objects.requireNonNull(Connection.getCurrent());
|
||||
String projectId = ProjectBuildLogAppender.getProjectId();
|
||||
Message.ProjectEvent msg = Message.display(projectId, message);
|
||||
LOGGER.info("Sending display request: " + msg);
|
||||
LOGGER.info("Sending display request: {}", msg);
|
||||
con.dispatch(msg);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Unable to display message", e);
|
||||
@@ -167,9 +167,9 @@ public class DaemonPrompter extends AbstractInputHandler implements Prompter, In
|
||||
String projectId = ProjectBuildLogAppender.getProjectId();
|
||||
String uid = UUID.randomUUID().toString();
|
||||
Message.Prompt msg = new Message.Prompt(projectId, uid, message, password);
|
||||
LOGGER.info("Requesting prompt: " + msg);
|
||||
LOGGER.info("Requesting prompt: {}", msg);
|
||||
Message.PromptResponse res = con.request(msg, Message.PromptResponse.class, r -> uid.equals(r.getUid()));
|
||||
LOGGER.info("Received response: " + res.getMessage());
|
||||
LOGGER.info("Received response: {}", res.getMessage());
|
||||
return res.getMessage();
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Unable to prompt user", e);
|
||||
|
Reference in New Issue
Block a user