Browse Source

Merge pull request #22112 from dreis2211

* gh-22112:
  Cleanup temporary files after Maven plugin execution

Closes gh-22112
pull/22996/head
Andy Wilkinson 6 years ago
parent
commit
0566c29e34
  1. 11
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SizeCalculatingEntryWriter.java

11
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SizeCalculatingEntryWriter.java

@ -98,8 +98,7 @@ final class SizeCalculatingEntryWriter implements EntryWriter { @@ -98,8 +98,7 @@ final class SizeCalculatingEntryWriter implements EntryWriter {
private OutputStream outputStream;
SizeCalculatingOutputStream() throws IOException {
this.tempFile = File.createTempFile("springboot-", "-entrycontent");
SizeCalculatingOutputStream() {
this.outputStream = new ByteArrayOutputStream();
}
@ -119,11 +118,19 @@ final class SizeCalculatingEntryWriter implements EntryWriter { @@ -119,11 +118,19 @@ final class SizeCalculatingEntryWriter implements EntryWriter {
}
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();

Loading…
Cancel
Save