Skip to content

Commit 2b982e8

Browse files
committed
Prevent blocking if there are large output on error stream of a process.
1 parent 67150bb commit 2b982e8

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/com/inet/gradle/setup/abstracts/AbstractBuilder.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import java.io.OutputStream;
2222
import java.util.ArrayList;
2323
import java.util.Arrays;
24-
import java.util.concurrent.Executor;
2524

2625
import org.gradle.api.internal.file.FileResolver;
2726
import org.gradle.initialization.DefaultBuildCancellationToken;
27+
import org.gradle.internal.concurrent.DefaultExecutorFactory;
2828
import org.gradle.process.internal.DefaultExecAction;
2929

3030
import com.inet.gradle.setup.util.IndentationOutputStream;
@@ -132,19 +132,9 @@ protected void exec( ArrayList<String> parameters, InputStream input, OutputStre
132132
/*// if gradleVersion < 4.5
133133
DefaultExecAction action = new DefaultExecAction( fileResolver );
134134
//// elif gradleVersion < 4.8
135-
DefaultExecAction action = new DefaultExecAction( fileResolver, new Executor() {
136-
@Override
137-
public void execute( Runnable command ) {
138-
command.run();
139-
}
140-
} );
135+
DefaultExecAction action = new DefaultExecAction( fileResolver, new DefaultExecutorFactory().create( "exec setup" ) );
141136
*/// else
142-
DefaultExecAction action = new DefaultExecAction( fileResolver, new Executor() {
143-
@Override
144-
public void execute( Runnable command ) {
145-
command.run();
146-
}
147-
}, new DefaultBuildCancellationToken());
137+
DefaultExecAction action = new DefaultExecAction( fileResolver, new DefaultExecutorFactory().create( "exec setup" ), new DefaultBuildCancellationToken());
148138
//// endif
149139
action.setCommandLine( parameters );
150140
action.setIgnoreExitValue( ignoreExitValue );
@@ -156,6 +146,7 @@ public void execute( Runnable command ) {
156146
output = new IndentationOutputStream( System.out );
157147
}
158148
action.setStandardOutput( output );
149+
action.setErrorOutput( output );
159150
try {
160151
action.execute();
161152
output.flush();

src/com/inet/gradle/setup/util/IndentationOutputStream.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ public void flush() throws IOException {
5959
}
6060
super.flush();
6161
}
62+
63+
/**
64+
* {@inheritDoc}
65+
*/
66+
@Override
67+
public void close() throws IOException {
68+
// Ignore to not close System.out
69+
}
6270
}

0 commit comments

Comments
 (0)