From cb686673a70a6f14c35575550c48c37d19a1598b Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Thu, 8 Mar 2018 13:17:00 +0100 Subject: [PATCH] LANG-1384: Fix NPE when version >= 11 The fix is likely to be insufficient if the version naming scheme changes. --- src/main/java/org/apache/commons/lang3/JavaVersion.java | 2 ++ src/test/java/org/apache/commons/lang3/JavaVersionTest.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java index a07445363..60258f63a 100644 --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java @@ -191,6 +191,8 @@ public enum JavaVersion { if (Float.parseFloat(nom.substring(firstComma + 1, end)) > .9f) { return JAVA_RECENT; } + } else if (v > 10) { + return JAVA_RECENT; } return null; } diff --git a/src/test/java/org/apache/commons/lang3/JavaVersionTest.java b/src/test/java/org/apache/commons/lang3/JavaVersionTest.java index 4d4202c49..ad285654f 100644 --- a/src/test/java/org/apache/commons/lang3/JavaVersionTest.java +++ b/src/test/java/org/apache/commons/lang3/JavaVersionTest.java @@ -59,6 +59,7 @@ public class JavaVersionTest { assertEquals("1.10 failed", JAVA_RECENT, get("1.10")); // assertNull("2.10 unexpectedly worked", get("2.10")); assertEquals("Wrapper method failed", get("1.5"), getJavaVersion("1.5")); + assertEquals("Unhandled", JAVA_RECENT, get("11")); // LANG-1384 } @Test