Skip to content

Commit

Permalink
Merge branch '2.3.x'
Browse files Browse the repository at this point in the history
Closes gh-22328
  • Loading branch information
wilkinsona committed Jul 14, 2020
2 parents 2642b04 + 0566c29 commit 972aab1
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ private static class SizeCalculatingOutputStream extends OutputStream {

private OutputStream outputStream;

SizeCalculatingOutputStream() throws IOException {
this.tempFile = File.createTempFile("springboot-", "-entrycontent");
SizeCalculatingOutputStream() {
this.outputStream = new ByteArrayOutputStream();
}

Expand All @@ -119,11 +118,19 @@ public void write(byte[] b, int off, int len) throws IOException {
}

private OutputStream convertToFileOutputStream(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
initializeTempFile();
FileOutputStream fileOutputStream = new FileOutputStream(this.tempFile);
StreamUtils.copy(byteArrayOutputStream.toByteArray(), fileOutputStream);
return fileOutputStream;
}

private void initializeTempFile() throws IOException {
if (this.tempFile == null) {
this.tempFile = File.createTempFile("springboot-", "-entrycontent");
this.tempFile.deleteOnExit();
}
}

@Override
public void close() throws IOException {
this.outputStream.close();
Expand Down

0 comments on commit 972aab1

Please sign in to comment.