From eaf4a0a2861c1246316265b11341469b118a4508 Mon Sep 17 00:00:00 2001 From: Sebastien Tardif Date: Sat, 30 May 2026 08:19:15 -0700 Subject: [PATCH] Close FileOutputStream delegate in InspectingOutputStream InspectingOutputStream extends OutputStream but does not override close(). When content exceeds MEMORY_LIMIT (approximately 4 KB), convertToTempFile() replaces the ByteArrayOutputStream delegate with a FileOutputStream. The try-with-resources in InspectedContent.of() calls close(), which inherits the no-op OutputStream.close(), leaving the FileOutputStream open and leaking a file descriptor. Override close() to delegate to the underlying stream. See gh-50639 Signed-off-by: Sebastien Tardif --- .../boot/buildpack/platform/io/InspectedContent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java index 96cc8a5820f..4bc65327f72 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java @@ -146,6 +146,11 @@ public class InspectedContent implements Content { this.delegate = new ByteArrayOutputStream(); } + @Override + public void close() throws IOException { + this.delegate.close(); + } + @Override public void write(int b) throws IOException { this.singleByteBuffer[0] = (byte) (b & 0xFF);