Skip to content

TIKA-4704: add delete on exit in case delete fails - #2717

Merged
THausherr merged 2 commits into
branch_3xfrom
TIKA-4704
Mar 29, 2026
Merged

TIKA-4704: add delete on exit in case delete fails#2717
THausherr merged 2 commits into
branch_3xfrom
TIKA-4704

Conversation

@THausherr

Copy link
Copy Markdown
Contributor

Thanks for your contribution to Apache Tika! Your help is appreciated!

Before opening the pull request, please verify that

  • there is an open issue on the Tika issue tracker which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes.
  • the issue ID (TIKA-XXXX)
    • is referenced in the title of the pull request
    • and placed in front of your commit messages surrounded by square brackets ([TIKA-XXXX] Issue or pull request title)
  • commits are squashed into a single one (or few commits for larger changes)
  • Tika is successfully built and unit tests pass by running ./mvnw clean test
  • there should be no conflicts when merging the pull request branch into the recent main branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled main branch
  • if you add new module that downstream users will depend upon add it to relevant group in tika-bom/pom.xml.

We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the Tika mailing list. Thanks!

Copilot AI review requested due to automatic review settings March 29, 2026 13:02
@THausherr THausherr changed the title TIKA-4704: delete on exit in case delete fails TIKA-4704: add delete on exit in case delete fails Mar 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses TIKA-4704 by ensuring the temporary bootstrap JAR created for forked parsing is scheduled for deletion at JVM shutdown if it can’t be deleted during ForkClient.close().

Changes:

  • Register the fork bootstrap JAR for deleteOnExit() during ForkClient.close().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tika-core/src/main/java/org/apache/tika/fork/ForkClient.java Outdated
}
if (jar != null) {
jar.delete();
jar.deleteOnExit();

Copilot AI Mar 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File#deleteOnExit() can throw SecurityException. Since close() currently doesn’t declare/expect to throw and is used in failure-cleanup paths, this new call can cause unexpected runtime failure during cleanup. Please guard the deleteOnExit() call (and any conditional logic around it) to keep close() best-effort.

Suggested change
jar.deleteOnExit();
try {
jar.deleteOnExit();
} catch (SecurityException ignore) {
// best-effort cleanup; ignore inability to register deleteOnExit
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be a SecurityException because it's our own file.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@THausherr
THausherr merged commit d367873 into branch_3x Mar 29, 2026
1 check passed
@tballison
tballison deleted the TIKA-4704 branch September 3, 2026 21:55
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