Skip to content

Commit 807bfbc

Browse files
authored
Merge pull request #48959 from Karm/issue-48946
Avoids some WARNINGs from io.smallrye.common.process.Logging
2 parents 5c9cd52 + b07355f commit 807bfbc

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildContainerRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ private void pull(String effectiveBuilderImage, boolean processInheritIODisabled
104104
pb.output().inherited().error().inherited();
105105
}
106106
try {
107-
pb.run();
107+
// logOnSuccess(false) avoids WARNING from io.smallrye.common.process.Logging
108+
pb.error().logOnSuccess(false).run();
108109
} catch (Exception e) {
109110
throw new RuntimeException("Failed to pull builder image '" + effectiveBuilderImage + "'", e);
110111
}

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunner.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public void build(List<String> args, String nativeImageName, String resultingExe
7171
}
7272
})
7373
.output().consumeLinesWith(8192, log::info)
74-
.error().consumeWith(br -> new ErrorReplacingProcessReader(br, outputDir.resolve("reports").toFile()).run())
74+
// Why logOnSuccess(false) and then consumeWith? Because we get the stdErr twice otherwise.
75+
.error().logOnSuccess(false)
76+
.consumeWith(br -> new ErrorReplacingProcessReader(br, outputDir.resolve("reports").toFile()).run())
7577
.run();
7678
boolean objcopyExists = objcopyExists();
7779

@@ -121,12 +123,13 @@ protected void postBuild(Path outputDir, String nativeImageName, String resultin
121123
static void runCommand(String[] command, String errorMsg, File workingDirectory) {
122124
log.info(String.join(" ", command).replace("$", "\\$"));
123125
try {
124-
var pb = ProcessBuilder.newBuilder(command[0])
126+
final ProcessBuilder<Void> pb = ProcessBuilder.newBuilder(command[0])
125127
.arguments(Arrays.copyOfRange(command, 1, command.length));
126128
if (workingDirectory != null) {
127129
pb.directory(workingDirectory.toPath());
128130
}
129-
pb.run();
131+
// Without logOnSuccess(false) the error stream is printed twice and with a "WARNING".
132+
pb.error().logOnSuccess(false).run();
130133
} catch (Exception e) {
131134
if (errorMsg != null) {
132135
log.errorf(e, errorMsg);

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.quarkus.deployment.pkg.steps;
22

33
import static io.quarkus.deployment.builditem.nativeimage.UnsupportedOSBuildItem.Arch.AMD64;
4+
import static io.smallrye.common.process.ProcessBuilder.newBuilder;
45

56
import java.io.File;
67
import java.io.IOException;
@@ -59,7 +60,6 @@
5960
import io.quarkus.sbom.ApplicationManifestConfig;
6061
import io.smallrye.common.os.OS;
6162
import io.smallrye.common.process.AbnormalExitException;
62-
import io.smallrye.common.process.ProcessBuilder;
6363
import io.smallrye.common.process.ProcessUtil;
6464

6565
public class NativeImageBuildStep {
@@ -566,7 +566,8 @@ private static String detectPIE() {
566566

567567
private static String testGCCArgument(String argument) {
568568
try {
569-
ProcessBuilder.exec("cc", "-v", "-E", argument, "-");
569+
newBuilder("cc", "-v", "-E", argument, "-")
570+
.error().logOnSuccess(log.isTraceEnabled()).run();
570571
return argument;
571572
} catch (Exception ignored) {
572573
return "";

0 commit comments

Comments
 (0)