8000 Remove incomplete native-library resources after extraction failure by RicheyWorks · Pull Request #54 · jcuda/jcuda · GitHub
[go: up one dir, main page]

Skip to content

Remove incomplete native-library resources after extraction failure - #54

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/failed-library-extraction
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/failed-library-extraction

Conversation

@RicheyWorks
Copy link
Copy Markdown

If reading or writing a packaged native-library resource fails after extraction starts, LibUtils.writeResourceToFile leaves a partial file behind. Later resource loads see that file as existing, skip extraction, and attempt to load the incomplete file. A transient extraction failure can therefore poison subsequent attempts using the same temp path.

Track successful completion of copying/flush. After closing the streams, remove incomplete output created by this attempt when possible; log a warning if cleanup fails. Keep the original exception and preserve the existing rule that a pre-existing target is rejected without modifying it. Successful extraction remains unchanged.

Three no-CUDA tests use an isolated class loader to inject a resource stream that fails after four bytes, without adding production test hooks or loading any native library:

  • Partial output is removed and the next extraction to the same path succeeds with the exact full bytes. This case fails on unchanged upstream.
  • A pre-existing file is rejected and preserved byte-for-byte.
  • A missing resource does not create an output file.

Validation: Maven/JUnit4.13.1, three tests, zero failures/errors/skips after the fix; baseline three tests with one failure. Windows/Temurin22, using the disclosed isolated parent source/target8 adaptation because upstream's Java7 target is rejected by this JDK. No POM changes, native DLLs, GPU tests, or system-property changes are included/needed.

This prevents new leftover partial files after a failed copy. It does not repair already-existing damaged files, introduce atomic cross-process extraction, or validate native-library loading on other platforms. Cleanup is best-effort when the filesystem refuses deletion.

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.

1 participant

0