Skip to content

Commit 4e39fc3

Browse files
committed
Recordify WatchedOutput
1 parent 21c24ae commit 4e39fc3

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

platform-tooling-support-tests/src/main/java/platform/tooling/support/process/WatchedOutput.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,11 @@
1313
import java.io.ByteArrayOutputStream;
1414
import java.nio.charset.Charset;
1515

16-
public class WatchedOutput {
16+
record WatchedOutput(Thread thread, ByteArrayOutputStream stream) {
1717

1818
private static final Charset CHARSET = Charset.forName(System.getProperty("native.encoding"));
1919

20-
private final Thread thread;
21-
private final ByteArrayOutputStream stream;
22-
23-
WatchedOutput(Thread thread, ByteArrayOutputStream stream) {
24-
this.thread = thread;
25-
this.stream = stream;
26-
}
27-
28-
void join() throws InterruptedException {
29-
thread.join();
30-
}
31-
32-
public String getStreamAsString() {
20+
String streamAsString() {
3321
return stream.toString(CHARSET);
3422
}
3523
}

platform-tooling-support-tests/src/main/java/platform/tooling/support/process/WatchedProcess.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ ProcessResult waitFor() throws InterruptedException {
3636
}
3737
finally {
3838
try {
39-
out.join();
39+
out.thread().join();
4040
}
4141
finally {
42-
err.join();
42+
err.thread().join();
4343
}
4444
}
45-
return new ProcessResult(exitCode, out.getStreamAsString(), err.getStreamAsString());
45+
return new ProcessResult(exitCode, out.streamAsString(), err.streamAsString());
4646
}
4747
finally {
4848
process.destroyForcibly();

0 commit comments

Comments
 (0)