You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2023/03/12 22:08:39 UTC
[maven-mvnd] 02/03: Use String.join() instead of Collectors.joining() where applicable
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
commit 3657375e97d0899cd603cf002dc0273da16cc8ab
Author: Petr Široký <pe...@pm.me>
AuthorDate: Fri Mar 10 22:14:14 2023 +0100
Use String.join() instead of Collectors.joining() where applicable
* the String.join() is more readable and there should not be any
downsides (like performance or so)
---
.../java/org/mvndaemon/mvnd/common/OsUtils.java | 27 +++++++---------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java b/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
index 05eb4d2e..e829ade5 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,14 +78,11 @@ public class OsUtils {
} catch (NumberFormatException e) {
LOGGER.warn(
"Could not parse the output of {} as a long:\n{}",
- Stream.of(cmd).collect(Collectors.joining(" ")),
- output.stream().collect(Collectors.joining("\n")));
+ String.join(" ", cmd),
+ String.join("\n", output));
}
} else {
- LOGGER.warn(
- "Unexpected output of {}:\n{}",
- Stream.of(cmd).collect(Collectors.joining(" ")),
- output.stream().collect(Collectors.joining("\n")));
+ LOGGER.warn("Unexpected output of {}:\n{}", String.join(" ", cmd), String.join("\n", output));
}
return -1;
} else if (os == Os.WINDOWS) {
@@ -101,14 +97,11 @@ public class OsUtils {
} catch (NumberFormatException e) {
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")));
+ String.join(" ", cmd),
+ String.join("\n", nonEmptyLines));
}
} else {
- LOGGER.warn(
- "Unexpected output of {}:\n{}",
- Stream.of(cmd).collect(Collectors.joining(" ")),
- output.stream().collect(Collectors.joining("\n")));
+ LOGGER.warn("Unexpected output of {}:\n{}", String.join(" ", cmd), String.join("\n", output));
}
return -1;
} else {
@@ -140,14 +133,10 @@ public class OsUtils {
try (CommandProcess ps = new CommandProcess(builder.start(), output::add)) {
final int exitCode = ps.waitFor(1000);
if (exitCode != 0) {
- LOGGER.warn(
- "{} exited with {}:\n{}",
- Stream.of(cmd).collect(Collectors.joining(" ")),
- exitCode,
- output.stream().collect(Collectors.joining("\n")));
+ LOGGER.warn("{} exited with {}:\n{}", String.join(" ", cmd), exitCode, String.join("\n", output));
}
} catch (IOException e) {
- LOGGER.warn("Could not execute {}", Stream.of(cmd).collect(Collectors.joining(" ")));
+ LOGGER.warn("Could not execute {}", String.join(" ", cmd));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}