Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-48738] Fix NPE when setting JDK #203

Merged
merged 1 commit into from
May 21, 2023

Conversation

MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented May 21, 2023

Fix null pointer exception when setting JDK

See the original proposed change at a15d15a

Confirmed with interactive testing that the null pointer exception is resolved and that the configuration slicing plugin can change the value of the JDK that is defined on a Freestyle job. I changed between jdk-8 and jdk-20.

The plugin cannot reset the definition of the JDK to the default because that causes a null pointer exception in AbstractProject as reported by the original bug report JENKINS-48738

Avoid the null pointer exception by ignoring the attempt to reset the JDK value to default.

Thanks to @Evildethow and @ahertier for implementation

Testing done

Interactive testing of freestyle project with Jenkins 2.401. I configured two JDK tool values, jdk-8 and jdk-20, then assigned one of the values to the job. The configuration slicing plugin with this change is able to change the configuration from jdk-8 to jdk-20 and from jdk-20 to jdk-8. The attempt to change JDK to an empty string is sliently ignored rather than generating a null pointer exception.

AbstractProject does not seem to have a method that will allow the JDK of a project to be reset to the default value. The user interface is able to make that change, but apparently it makes the change without passing a null to setJDK().

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 demonstrates feature works or fixes the issue

jenkinsci@a15d15a

Confirmed with interactive testing that the null pointer exception is
resolved and that the configuration slicing plugin can change the value
of the JDK that is defined on a Freestyle job.  I changed between jdk-8
and jdk-20.

The plugin cannot reset the definition of the JDK to the default because
that causes a null pointer exception in AbstractProject as reported by
the original bug report https://issues.jenkins.io/browse/JENKINS-48738

Avoid the null pointer exception by ignoring the attempt to reset the
JDK value to default.

Thanks to @Evildethow and @ahertier for implementation
@MarkEWaite MarkEWaite merged commit e92d48e into jenkinsci:master May 21, 2023
@MarkEWaite MarkEWaite deleted the fix-jdk-slicer-NPE branch May 21, 2023 13:42
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