Skip to content

JENKINS-75299 Jenkins not starting due to NPE#179

Merged
mtughan merged 1 commit intojenkinsci:mainfrom
Satvik01000:jenkins-75299-npe-in-scriptler-plugin
Jan 1, 2026
Merged

JENKINS-75299 Jenkins not starting due to NPE#179
mtughan merged 1 commit intojenkinsci:mainfrom
Satvik01000:jenkins-75299-npe-in-scriptler-plugin

Conversation

@Satvik01000
Copy link
Contributor

Context

Fixes JENKINS-75299.

The plugin causes a NullPointerException during Jenkins startup if the scriptler.xml configuration file is corrupted by missing the <scriptSet> tag (e.g., due to manual editing, merge conflicts, or migration issues).

Because the scriptSet field in ScriptSet.java was marked final, XStream would leave it as null when the tag was missing, and the code could not re-initialize it, leading to a crash when getScripts() was called. It was discovered that the same issue was occurring in setScripts() aswell.

Changes

  • ScriptSet.java: Removed the final modifier from the scriptSet field.
  • Null Safety: Updated getScripts() and setScripts() to check if scriptSet is null. If it is, the code now initializes an empty TreeSet instead of crashing.
  • Testing: Added a test for the issue.

Testing done

Automated Testing:

  • Added a new test file: src/test/java/org/jenkinsci/plugins/scriptler/config/ScriptSetTest.java.
  • The test explicitly sets the internal scriptSet field to null (simulating the XStream deserialization issue) and asserts that getScripts() returns an empty set instead of throwing an NPE.
  • Ran mvn test: All 78 tests passed.

Manual Verification:

  • Reproduction: Manually edited work/scriptler.xml to remove the <scriptSet> tag.
  • Before Fix: Verified that running mvn hpi:run caused a java.lang.NullPointerException stack trace during startup, which stopped Jenkins from running.
  • After Fix: Verified that Jenkins starts up successfully with the same corrupted file, and the plugin functions correctly (self-heals).

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@mtughan mtughan merged commit 1420c0e into jenkinsci:main Jan 1, 2026
17 checks passed
@mtughan mtughan added the bugfix label Jan 1, 2026
@Satvik01000 Satvik01000 deleted the jenkins-75299-npe-in-scriptler-plugin branch January 1, 2026 17:48
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.

2 participants