Skip to content

fix: lower native library candidate log level from WARNING to DEBUG (fixes #2185) - #2192

Merged
gnodet merged 1 commit into
masterfrom
fix/2185-lower-native-loader-log-level
Aug 26, 2026
Merged

fix: lower native library candidate log level from WARNING to DEBUG (fixes #2185)#2192
gnodet merged 1 commit into
masterfrom
fix/2185-lower-native-loader-log-level

Conversation

@gnodet

@gnodet gnodet commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Lower log level in loadNativeLibrary() from WARNING to DEBUG for failed native library candidates that the fallback chain recovers from
  • The unrecoverable case (all candidates fail) already throws from loadJLineNativeLibrary() with full triedPaths, so no diagnostic information is lost
  • Eliminates a deadlock path where the WARNING log re-enters static synchronized initialize() through application logging bridges that render to the terminal being built

Context

When library.jline.path is set (e.g. Maven sets it to ${maven.home}/lib/jline-native), a failure of the first candidate warns even though the next step succeeds. The System.Logger WARNING is bridged by applications into their own logging, and if that logging renders through the terminal currently being constructed, the thread parks inside the static synchronized initialize() lock — blocking every other terminal build in the JVM.

Reported in #2185, observed in Maven (apache/maven#12814, apache/maven-executor#38).

Summary by CodeRabbit

  • Bug Fixes
    • Reduced the visibility of expected native library load-failure messages to avoid unnecessary warning notifications.
    • Updated related documentation to reflect the revised logging behavior.

…ixes #2185)

loadNativeLibrary() is called as part of a fallback chain that tries
multiple candidate paths. A failed candidate is expected and recovered
from by the next step, so WARNING is too noisy — the genuinely
unrecoverable case already throws from loadJLineNativeLibrary().

The WARNING also causes a practical problem: applications that bridge
System.Logger into terminal-backed logging re-enter initialize() through
the static synchronized lock, deadlocking every thread that tries to
build a terminal.

Lowering to DEBUG keeps the diagnostic available when needed without
triggering application-level logging on every recovered candidate.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 608c7d78-f453-4ef3-9c95-c43c62223b69

📥 Commits

Reviewing files that changed from the base of the PR and between 59a03f0 and 7eb02c9.

📒 Files selected for processing (1)
  • native/src/main/java/org/jline/nativ/JLineNativeLoader.java

Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The native loader now logs failed native library loads at DEBUG level instead of WARNING level. The related documentation now states the DEBUG-level behavior. The method still returns false after a load failure.

Changes

Native load logging

Layer / File(s) Summary
Update native load failure logging
native/src/main/java/org/jline/nativ/JLineNativeLoader.java
loadNativeLibrary logs failed native library loads at Level.DEBUG and still returns false. The documentation reflects the DEBUG-level behavior.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 7eb02

The change lowers logging for recoverable native-library candidates without changing the fallback behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: lowering native library candidate failure logs from WARNING to DEBUG. It also references the related issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2185-lower-native-loader-log-level

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.

@sonarqubecloud

Copy link
Copy Markdown

@gnodet gnodet left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM — Clean, minimal fix that correctly lowers a log level from WARNING to DEBUG for expected/recovered native library candidate failures.

The change is correct:

  • loadNativeLibrary() is called as part of a fallback chain — failure of any single candidate is expected and recovered by the next candidate. WARNING is inappropriate for a recovered condition.
  • No diagnostic information is lost: the unrecoverable case throws with all triedPaths joined, providing full context when all candidates fail.
  • The deadlock scenario is real and well-documented in #2185System.Logger WARNING bridged to application logging that re-enters static synchronized initialize().
  • The Javadoc update ("logs the error at DEBUG level") is consistent with the code change.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone (none) 4.4.0

🔀 Backport Status

⚠️ This bug fix targets master but no backport was found for:

  • 4.0.x — has the identical WARNING at the same location. Since this fixes a deadlock affecting real users (Maven), a cherry-pick should be straightforward.
  • jline-3.x — may also warrant a backport but uses a different logging mechanism and would need adaptation.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet

@gnodet gnodet added the bug label Aug 26, 2026
@gnodet gnodet self-assigned this Aug 26, 2026
@gnodet gnodet added this to the 4.4.0 milestone Aug 26, 2026
@gnodet
gnodet merged commit 30dc52b into master Aug 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant