Skip to content

Commit

Permalink
[JENKINS-48738] Fix JDK configuration NPE (#203)
Browse files Browse the repository at this point in the history
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 authored May 21, 2023
1 parent 1da0636 commit e92d48e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/configurationslicing/jdk/JdkSlicer.java
Original file line number Diff line number Diff line change
@@ -64,7 +64,9 @@ public boolean setValues(AbstractProject item, List<String> set) {
JDK oldJdk = item.getJDK();
if (!equals(oldJdk, jdk)) {
try {
item.setJDK(jdk);
if (jdk != null) {
item.setJDK(jdk);
}
return true;
} catch (IOException e) {
e.printStackTrace();

0 comments on commit e92d48e

Please sign in to comment.