Skip to content

Commit 60fc3dc

Browse files
committed
Fix JBangSupport process exec so it cannot hang
1 parent d8618ec commit 60fc3dc

File tree

1 file changed

+6
-4
lines changed
  • independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin

1 file changed

+6
-4
lines changed

independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.nio.file.Path;
1414
import java.nio.file.Paths;
1515
import java.util.ArrayList;
16+
import java.util.Arrays;
1617
import java.util.List;
1718
import java.util.Locale;
1819
import java.util.Optional;
@@ -105,17 +106,18 @@ public List<String> getCommand() {
105106

106107
public List<String> execute(String... args) {
107108
try {
108-
List<String> command = new ArrayList<>();
109+
List<String> command = new ArrayList<>(args.length + 1);
109110
command.add(getExecutable().getAbsolutePath());
110-
for (String arg : args) {
111-
command.add(arg);
112-
}
111+
command.addAll(Arrays.asList(args));
113112
List<String> lines = new ArrayList<>();
114113
try {
115114
Process process = new ProcessBuilder()
116115
.directory(workingDirectory.toFile())
116+
.redirectError(ProcessBuilder.Redirect.DISCARD)
117117
.command(command)
118118
.start();
119+
// make sure the process does not block waiting for input
120+
process.getOutputStream().close();
119121

120122
try (InputStreamReader isr = new InputStreamReader(process.getInputStream());
121123
BufferedReader reader = new BufferedReader(isr)) {

0 commit comments

Comments
 (0)