Skip to content

Commit e92d48e

Browse files
authored
[JENKINS-48738] Fix JDK configuration NPE (#203)
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
1 parent 1da0636 commit e92d48e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/configurationslicing/jdk/JdkSlicer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public boolean setValues(AbstractProject item, List<String> set) {
6464
JDK oldJdk = item.getJDK();
6565
if (!equals(oldJdk, jdk)) {
6666
try {
67-
item.setJDK(jdk);
67+
if (jdk != null) {
68+
item.setJDK(jdk);
69+
}
6870
return true;
6971
} catch (IOException e) {
7072
e.printStackTrace();

0 commit comments

Comments
 (0)