You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Driver and agent leak file handles when an exception interrupts a stream #10
Several file streams in the driver and agent modules are opened and closed by hand instead of with try-with-resources. If anything throws between the open and the .close(), the handle leaks. On Windows a leaked handle keeps the file locked, which then breaks later writes/deletes of the same pack folder (the write-path this fork focuses on).
Description
Wrap every manually closed stream in try-with-resources so the handle is released even when an exception is thrown mid-way. Pure robustness change, no behaviour change on the happy path.
Fichiers concernes
driver/src/main/java/studio/driver/fs/CipherUtils.java:56-64 (addBootFileV2) — FileInputStream riFis and FileOutputStream btFos closed by hand
driver/src/main/java/studio/driver/raw/RawStoryTellerAsyncDriver.java:516-518 (dumpSector) — FileOutputStream sectorOutputStream closed after writeByteBufferToStream, which can throw
agent/src/main/java/studio/agent/UnofficialMetadataAdvice.java:59-62 — FileOutputStream fos around a Base64.decode + write
driver/src/test/java/studio/driver/fs/CipherUtilsStreamLifecycleTest.java (new) — forces a failure after the stream is opened and asserts the file is not locked / handle released
Existing patterns to reuse: driver/src/test/java/studio/driver/fs/FilesWalkResourceLeakTest.java, web-ui/src/test/java/studio/webui/service/ConversionStreamLifecycleTest.java
Plan d'implementation
CipherUtils.addBootFileV2: try-with-resources on both streams.
RawStoryTellerAsyncDriver.dumpSector: try-with-resources on sectorOutputStream.
UnofficialMetadataAdvice: try-with-resources on fos.
Add a stream-lifecycle test for addBootFileV2 (e.g. truncated/unreadable ri file) that asserts the boot file can be deleted afterwards, which is the observable Windows symptom.
mvn -pl driver,agent test green.
Criteres d'acceptation
No manual .close() left on these three sites; all use try-with-resources
New test fails on the old code (handle leaked) and passes on the fix
mvn -pl driver,agent test green on Ubuntu and Windows CI
git diff --exit-code clean after the build (no tracked file rewritten)
try-with-resources on CipherUtils.addBootFileV2, RawStoryTellerAsyncDriver.dumpSector, UnofficialMetadataAdvice
new BootFileStreamLifecycleTest (5 tests) pinning the nominal contract of addBootFileV2; the failure path is not injectable from outside (documented in the test javadoc), so this is a fix by inspection
CI green on Ubuntu, Windows and Web UI; git diff --exit-code clean
Activity
lgnap commentedon Sep 11, 2026
Prise en charge par Claude Code (instance
tuxedo:40112:d397e957, branchefix/issue-10-driver-stream-leaks).lgnap commentedon Sep 11, 2026
Implemented in antoinevalentinHA#56 (branch
fix/issue-10-driver-stream-leaks).CipherUtils.addBootFileV2,RawStoryTellerAsyncDriver.dumpSector,UnofficialMetadataAdviceBootFileStreamLifecycleTest(5 tests) pinning the nominal contract ofaddBootFileV2; the failure path is not injectable from outside (documented in the test javadoc), so this is a fix by inspectiongit diff --exit-codecleanAwaiting review/merge by the upstream owner.