Skip to content

Jenkins 36720 spotbugs cleanup#26082

Closed
Satvik01000 wants to merge 3 commits intojenkinsci:masterfrom
Satvik01000:jenkins-36720-spotbugs-cleanup
Closed

Jenkins 36720 spotbugs cleanup#26082
Satvik01000 wants to merge 3 commits intojenkinsci:masterfrom
Satvik01000:jenkins-36720-spotbugs-cleanup

Conversation

@Satvik01000
Copy link

Fixes JENKINS-36720.

Description

This PR contributes to fixing the SpotBugs technical debt in the CLI module. In this PR, the fix is for the potential NPE in BuildCommand.java and DeleteNodeCommand.java

Changes:

  1. hudson.cli.BuildCommand.java:
  • The run() method was accessing .ordinal on b.getResult().
  • Fix: Added a null check. If the result is null, it now returns -1 instead of throwing an NPE.
  1. hudson.cli.DeleteNodeCommand.java:
  • The run() method was calling .doDoDelete() on node.toComputer().
  • Fix: Added a null check. If the computer is null, it now throws an IllegalStateException. This allows the existing catch block to handle the error, print it to stderr, and continue the loop to process other nodes.
  1. excludesFilter.xml:
  • Removed the now-resolved exclusions for these two classes.

Testing done

Verified that the changes compile and pass static analysis locally.

  • Executed mvn spotbugs:check -> BUILD SUCCESS (0 bugs found).
  • Executed mvn test -pl core -> BUILD SUCCESS.

No new unit tests were added as these are safety checks for race conditions/edge cases that are difficult to reproduce in a unit test environment without mocking internal core states.

Screenshots (UI changes only)

N/A

Proposed changelog entries

  • Fix potential NullPointerExceptions in CLI build and delete-node commands reported by SpotBugs.

Proposed changelog category

/label bug

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see [examples](https://github.com/jenkins-infra/jenkins.io/blob/master/content/_data/changelogs/weekly.yml)). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of [Content Security Policy Plugin](https://plugins.jenkins.io/csp/). In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see [documentation](https://www.jenkins.io/doc/developer/security/csp/)).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@comment-ops-bot comment-ops-bot bot added the bug For changelog: Minor bug. Will be listed after features label Jan 7, 2026
@Satvik01000 Satvik01000 closed this Jan 9, 2026
@Satvik01000 Satvik01000 deleted the jenkins-36720-spotbugs-cleanup branch January 9, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant