Skip to content

Commit

Permalink
Merge pull request #780 from jonesbusy/feature/fix-possible-nullpointer
Browse files Browse the repository at this point in the history
Fix possible nullpointer if jenkinsVersion is null
  • Loading branch information
jonesbusy authored Feb 8, 2025
2 parents 8be9335 + 2ae773c commit 08d56c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ public static List<JDK> all() {
* @return The list of buildable JDKs
*/
public static List<JDK> get(String jenkinsVersion) {
if (jenkinsVersion == null || jenkinsVersion.isEmpty()) {
return List.of(JDK.min());
}
ComparableVersion jenkinsVersionComparable = new ComparableVersion(jenkinsVersion);
return Arrays.stream(JDK.values())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ recipeList:
type: specs.openrewrite.org/v1beta/recipe
name: io.jenkins.tools.pluginmodernizer.RemoveDevelopersTag
displayName: Remove developers tag
tags: ['chore']
tags: ['chore', 'skip-verification']
description: Remove developers tag from the pom.xml.
recipeList:
- org.openrewrite.xml.RemoveXmlTag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public void filter() {
@Test
public void getBuildableJdk() {

assertEquals(1, JDK.get(null).size());
assertEquals(JDK.JAVA_8, JDK.get(null).get(0));

assertEquals(1, JDK.get("2.163").size());
assertEquals(JDK.JAVA_8, JDK.get("2.163").get(0));

Expand Down Expand Up @@ -148,6 +151,10 @@ public void getBuildableJdk() {
assertEquals(2, JDK.get("2.479.1").size());
assertEquals(JDK.JAVA_17, JDK.get("2.479.1").get(0));
assertEquals(JDK.JAVA_21, JDK.get("2.479.1").get(1));

assertEquals(2, JDK.get("2.492.1").size());
assertEquals(JDK.JAVA_17, JDK.get("2.492.1").get(0));
assertEquals(JDK.JAVA_21, JDK.get("2.492.1").get(1));
}

@Test
Expand Down

0 comments on commit 08d56c5

Please sign in to comment.