Close DeferredFileOutputStream to prevent FileNotFoundException on temp files by Copilot · Pull Request #157 · codehaus-plexus/plexus-io (original) (raw)

Fixes #118. When using InputStreamTransformer with files exceeding the 5MB threshold, DeferredFileOutputStream creates temp files in /tmp but was never closed after writing. On Linux/macOS, subsequent reads fail with FileNotFoundException because the file isn't fully flushed to disk.

Changes

The existing cleanup logic (deleting temp file on InputStream close) remains unchanged.

Original prompt


This section details on the original issue you should resolve

<issue_title>plexus-io:3.3.0 error: tmp/maven-metadata-local.xml3261144141794286831.tmp (No such file or directory)</issue_title>
<issue_description>I upgrade plexus-io from 3.2.0 to 3.3.0 because of the CVE issue, and get error as:
[ERROR] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.2.7:kar (create-kar) on project testRoute-feature: Failed to create archive: Problem creating jar: Execution exception: java.io.FileNotFoundException: /tmp/maven-metadata-local.xml11604840448228358901.tmp (No such file or directory) -> [Help 1]
How to reproduce?
extract testRoute.zip,
execute in testRoute folder.
mvn -X -B package -llr -Dmaven.test.skip=true -Dmaven.main.skip=true

Note. This error only happens in Linux/mac os. details error see
mvn.log
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.