Skip to content

fix: use daemon thread for version check to prevent JVM hang#2524

Merged
maxandersen merged 1 commit into
jbangdev:mainfrom
stalep:fix/version-checker-hang
Jun 10, 2026
Merged

fix: use daemon thread for version check to prevent JVM hang#2524
maxandersen merged 1 commit into
jbangdev:mainfrom
stalep:fix/version-checker-hang

Conversation

@stalep

@stalep stalep commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #2523

Executors.newSingleThreadExecutor() creates non-daemon threads by default. After the version check task completes, the worker thread parks in LinkedBlockingQueue.take() waiting for tasks that never come, preventing JVM exit.

This causes jbang to occasionally hang indefinitely after a command completes.

Fix

Use a daemon thread factory with a descriptive thread name (jbang-version-check) so the JVM can exit normally when the main thread finishes.

Stack trace (from @maxandersen)

"pool-1-thread-1" #21 prio=5 cpu=216.66ms elapsed=112.83s
   java.lang.Thread.State: WAITING (parking)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:435)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1070)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    ...

"DestroyJavaVM" #22 prio=5 cpu=185.54ms elapsed=112.67s
   java.lang.Thread.State: RUNNABLE

…v#2523)

Executors.newSingleThreadExecutor() creates non-daemon threads by
default. After the version check completes, the worker thread parks
in LinkedBlockingQueue.take() waiting for tasks that never come,
preventing JVM exit.

Use a daemon thread factory with a descriptive thread name so the
JVM can exit normally when the main thread finishes.
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 96d776cd-1008-45a4-9df7-d52ac60a349e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@quintesse quintesse 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.

LGTM

@maxandersen maxandersen merged commit 38927ed into jbangdev:main Jun 10, 2026
30 checks passed
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.

jbang hangs after command completes due to non-daemon version check thread

3 participants