diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java index 37d73a2d8..7596688a9 100644 --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java @@ -282,6 +282,10 @@ public enum JavaVersion { return v > 0 ? v : 99f; } + static String[] split(final String value) { + return value.split(VERSION_SPLIT_REGEX); + } + /** * Parses a float value from a String. * @@ -293,7 +297,7 @@ public enum JavaVersion { if (!value.contains(".")) { return NumberUtils.toFloat(value, defaultReturnValue); } - final String[] toParse = value.split("\\."); + final String[] toParse = split(value); if (toParse.length >= 2) { return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue); } @@ -310,6 +314,11 @@ public enum JavaVersion { */ private final String name; + /** + * The regex to split version strings. + */ + private static final String VERSION_SPLIT_REGEX = "\\."; + /** * Constructs a new instance. * diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index 8d8f8a938..6dbdffc22 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -34,11 +34,6 @@ import java.io.File; */ public class SystemUtils { - /** - * The regex to split version strings. - */ - private static final String VERSION_SPLIT_REGEX = "\\."; - /** * The prefix String for all Windows OS. */ @@ -2155,8 +2150,8 @@ public class SystemUtils { } // Compare parts of the version string instead of using String.startsWith(String) because otherwise // osVersionPrefix 10.1 would also match osVersion 10.10 - final String[] versionPrefixParts = osVersionPrefix.split(VERSION_SPLIT_REGEX); - final String[] versionParts = osVersion.split(VERSION_SPLIT_REGEX); + final String[] versionPrefixParts = JavaVersion.split(osVersionPrefix); + final String[] versionParts = JavaVersion.split(osVersion); for (int i = 0; i < Math.min(versionPrefixParts.length, versionParts.length); i++) { if (!versionPrefixParts[i].equals(versionParts[i])) { return false;