Skip to content

Close the keystore file in SslContextAwareAbstractSource - #506

Merged
rgoers merged 3 commits into
trunkfrom
fix/close-keystore-stream
Sep 17, 2026
Merged

rgoers merged 3 commits into
trunkfrom
fix/close-keystore-stream

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

SslContextAwareAbstractSource loaded the keystore through a FileInputStream that was never closed, both when validating the configuration in configureSsl and each time getSslContext created an SSLContext. The leaked handle keeps the keystore locked on Windows until the stream is garbage collected.

This surfaced in apache/logging-flume-http#7: TestHTTPSource was migrated to JUnit 5, whose @TempDir cleanup reports files it cannot delete, and the Windows build failed on the still-open keystore.jks. JUnit 4's TemporaryFolder silently ignored the same failure here.

Changes

  • Load the keystore in a try-with-resources block in both places.
  • Add TestSslContextAwareAbstractSource, which checks the SSL context creation, the password validation, that the keystore can be deleted after use (the Windows symptom) and, on Linux, that no descriptor in /proc/self/fd still points at the keystore. Against the unfixed code the last test fails with two open descriptors.
  • Add a changelog entry.

🤖 Generated with Claude Code

The keystore was loaded through a `FileInputStream` that was never
closed, both when validating the configuration and each time an
`SSLContext` was created. The leaked handle keeps the keystore locked
on Windows until the stream is garbage collected, which makes tests that
place the keystore in a JUnit `@TempDir` fail during cleanup.

Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>
@ppkarwasz
ppkarwasz enabled auto-merge (squash) September 17, 2026 14:16
@ppkarwasz
ppkarwasz disabled auto-merge September 17, 2026 14:16
@rgoers
rgoers merged commit 9b5f6ba into trunk Sep 17, 2026
18 of 20 checks passed
@rgoers
rgoers deleted the fix/close-keystore-stream branch September 17, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants