Skip to content

Close FileOutputStream delegate in InspectingOutputStream#50639

Merged
snicoll merged 1 commit into
spring-projects:3.5.xfrom
SebTardif:close-inspecting-output-stream
May 31, 2026
Merged

Close FileOutputStream delegate in InspectingOutputStream#50639
snicoll merged 1 commit into
spring-projects:3.5.xfrom
SebTardif:close-inspecting-output-stream

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

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.

This commit overrides close() to delegate to the underlying stream.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 30, 2026
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 spring-projectsgh-50639

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@snicoll snicoll added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels May 31, 2026
@snicoll snicoll self-assigned this May 31, 2026
@snicoll snicoll added this to the 3.5.15 milestone May 31, 2026
@snicoll snicoll changed the base branch from main to 3.5.x May 31, 2026 14:14
@snicoll snicoll force-pushed the close-inspecting-output-stream branch from d65e645 to eaf4a0a Compare May 31, 2026 14:14
@snicoll snicoll merged commit cc90a08 into spring-projects:3.5.x May 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants