Skip to content

client: fix JAVA_HOME NPE at startup and malformed cmdQueueLimit token#905

Open
jutur wants to merge 1 commit into
btraceio:developfrom
jutur:fix-client-java-home-npe-and-cmd-queue-limit-token
Open

client: fix JAVA_HOME NPE at startup and malformed cmdQueueLimit token#905
jutur wants to merge 1 commit into
btraceio:developfrom
jutur:fix-client-java-home-npe-and-cmd-queue-limit-token

Conversation

@jutur

@jutur jutur commented Jul 15, 2026

Copy link
Copy Markdown

Main.getJavaVersion() ran inside the class's static initializer and called Paths.get(System.getenv("JAVA_HOME"), "release") unguarded. When JAVA_HOME isn't set, System.getenv() returns null and Paths.get(null, ..) throws NullPointerException -- only IOException was caught, so the NPE escaped as ExceptionInInitializerError and killed the CLI before it could start. Falls back to the java.home system property (the JVM the client itself is running on) when JAVA_HOME is unset or blank, and returns null (unknown version) only if neither is available.

Separately, Client.java built the --cmdQueueLimit agent argument as ",=" + Args.CMD_QUEUE_LIMIT + cmdQueueLimit instead of the "," + KEY + "=" + value pattern every other agent arg in this method follows. The leading "=" with no key meant the agent's parser saw a junk empty-key entry rather than a CMD_QUEUE_LIMIT value, so the setting was silently dropped.

Fixes #887, #886

What does this change do?

Related issue

Closes #

Scope and compatibility

  • I identified the affected module(s) and kept unrelated changes out of this PR.
  • This preserves the supported Java/runtime compatibility tiers, or the change is documented below.
  • This does not change the masked-JAR layout, class-loader boundary, or wire protocol.
  • If it does, I updated the relevant architecture documentation and verification plan.

Compatibility or migration notes:

Testing

  • Unit tests
  • Integration tests (if applicable)
  • spotlessCheck
  • Documentation/link or sample verification (if applicable)

Commands and results:

# Example:
# GRADLE_USER_HOME=$(pwd)/.gradle-user ./gradlew :module:test

Documentation and release impact

  • User-facing documentation is updated, or no documentation change is needed.
  • Release notes/changelog are updated, or no release-note entry is needed.
  • Samples, distribution contents, or published coordinates are updated if affected.
  • This change is safe to merge independently of a release, or the dependency is explained below.

Release notes / follow-up work:

Final checklist

  • I reviewed the complete diff and removed unrelated changes.
  • New or changed behavior has appropriate tests, or the reason for not adding them is explained above.
  • User-facing behavior, APIs, samples, and documentation are consistent with this change.
  • I did not include generated build output, local configuration, credentials, or other accidental files.

This change is Reviewable

Main.getJavaVersion() ran inside the class's static initializer and
called Paths.get(System.getenv("JAVA_HOME"), "release") unguarded. When
JAVA_HOME isn't set, System.getenv() returns null and Paths.get(null, ..)
throws NullPointerException -- only IOException was caught, so the NPE
escaped as ExceptionInInitializerError and killed the CLI before it
could start. Falls back to the java.home system property (the JVM the
client itself is running on) when JAVA_HOME is unset or blank, and
returns null (unknown version) only if neither is available.

Separately, Client.java built the --cmdQueueLimit agent argument as
",=" + Args.CMD_QUEUE_LIMIT + cmdQueueLimit instead of the "," + KEY +
"=" + value pattern every other agent arg in this method follows. The
leading "=" with no key meant the agent's parser saw a junk empty-key
entry rather than a CMD_QUEUE_LIMIT value, so the setting was silently
dropped.

Fixes btraceio#887, btraceio#886
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.

[3.0] Client fails to start with ExceptionInInitializerError when JAVA_HOME is unset

1 participant