Skip to content

Fix JGit resources not being closed in CLI commands#6795

Draft
pditommaso wants to merge 1 commit intomasterfrom
fix/close-jgit-resources
Draft

Fix JGit resources not being closed in CLI commands#6795
pditommaso wants to merge 1 commit intomasterfrom
fix/close-jgit-resources

Conversation

@pditommaso
Copy link
Member

@pditommaso pditommaso commented Feb 3, 2026

Summary

  • Make AssetManager implement Closeable interface
  • Wrap AssetManager usage in CLI commands with try-finally blocks to ensure close() is called
  • Prevents ~90 second shutdown delays caused by JGit shutdown hooks cleaning up unclosed Repository objects

Problem

JGit registers shutdown hooks when Repository objects are created. When these are not closed via close(), the cleanup runs during JVM shutdown, causing significant delays:

00:56:52.598 [Test worker] DEBUG java.lang.Runtime -- Runtime.exit() called with status: 0
java.lang.Throwable: Runtime.exit(0)
        at java.base/java.lang.Shutdown.logRuntimeExit(Shutdown.java:179)
        at java.base/java.lang.Shutdown.exit(Shutdown.java:160)
        at java.base/java.lang.Runtime.exit(Runtime.java:188)
        at java.base/java.lang.System.exit(System.java:1920)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:75)
00:58:26.391 [ForkJoinPool-1-worker-1] DEBUG o.e.jgit.internal.util.ShutdownHook – Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda/0x000000a801f07ad0@544df82e during JVM shutdown

Note the ~94 second gap between Runtime.exit(0) and JGit cleanup.

Changes

  • AssetManager.groovy: Added implements Closeable
  • CmdRun.groovy: Wrapped manager usage in try-finally
  • CmdPull.groovy: Wrapped manager usages in try-finally
  • CmdView.groovy: Wrapped manager usage in try-finally
  • CmdClone.groovy: Wrapped manager usage in try-finally
  • CmdInfo.groovy: Wrapped manager usage in try-finally
  • CmdConfig.groovy: Wrapped manager usage in try-finally
  • CmdDrop.groovy: Wrapped manager usage in try-finally

Test plan

  • Run make test to verify existing tests pass
  • Verify JGit shutdown delay is eliminated

AssetManager now implements Closeable and CLI commands wrap manager
usage in try-finally blocks to ensure JGit resources are properly
released. This prevents ~90 second shutdown delays caused by JGit
shutdown hooks cleaning up unclosed Repository objects.

Signed-off-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@netlify
Copy link

netlify bot commented Feb 3, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit ccbfcb2
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6981bc857fe9530007a40c82

@pditommaso pditommaso marked this pull request as draft February 3, 2026 09:17
@bentsherman bentsherman requested a review from jorgee February 3, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants