Skip to content

Commit 364142d

Browse files
authored
Read stdout of the process before waiting for it to complete. (#1951)
The issue is that the process can block on writing to stdout if the amount of data written is bigger than default buffer size. Hence not trying to read from the process until it finishes causes it to block forever trying to write to its stdout.
1 parent 8e8ee51 commit 364142d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/AffectedProjectFinder.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ Set<Project> find() {
6969
private static Set<String> changedPaths(File workDir) {
7070
try {
7171
Process process =
72-
Runtime.getRuntime().exec("git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}", null, workDir);
73-
process.waitFor();
74-
return ImmutableSet.copyOf(
75-
CharStreams.readLines(new InputStreamReader(process.getInputStream())));
72+
Runtime.getRuntime()
73+
.exec("git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}", null, workDir);
74+
try {
75+
return ImmutableSet.copyOf(
76+
CharStreams.readLines(new InputStreamReader(process.getInputStream())));
77+
} finally {
78+
process.waitFor();
79+
}
7680
} catch (IOException e) {
7781
throw new GradleException("Could not determine changed files", e);
7882
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)