Skip to content

Commit

Permalink
Close streams
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Aug 11, 2023
1 parent e1fbb7f commit 2694fe6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ public InputStream createReadStream() {
}

byte[] readAllBytes() {
InputStream stream = createReadStream();
final int bufLen = 1024 * 1024;
byte[] buf = new byte[bufLen];
int readLen;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); InputStream stream = createReadStream()) {
while ((readLen = stream.read(buf, 0, bufLen)) != -1) {
outputStream.write(buf, 0, readLen);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ private byte[] stopTracingImpl() {
try {
Files.createDirectories(tracePath.getParent());
Files.write(tracePath, data);
tracePath = null;
} catch (IOException e) {
throw new PlaywrightException("Failed to write trace file", e);
} finally {
tracePath = null;
}
}
return data;
Expand Down

0 comments on commit 2694fe6

Please sign in to comment.