LANG-1252: replacing system call for java 1.6 to SystemUtils.IS_JAVA_1_6

This commit is contained in:
Rob Tompkins 2016-09-11 10:54:59 -04:00
parent a266068798
commit b3c31a379e
2 changed files with 4 additions and 4 deletions

View File

@ -21,6 +21,7 @@
import java.math.BigInteger;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.Validate;
/**
@ -1407,8 +1408,6 @@ public static boolean isCreatable(final String str) {
boolean hasDecPoint = false;
boolean allowSigns = false;
boolean foundDigit = false;
boolean isJava6 = StringUtils.startsWith(
System.getProperty("java.version"), "1.6");
// deal with any possible sign up front
final int start = (chars[0] == '-' || chars[0] == '+') ? 1 : 0;
final boolean hasLeadingPlusSign = (start == 1 && chars[0] == '+');
@ -1481,7 +1480,7 @@ public static boolean isCreatable(final String str) {
}
if (i < chars.length) {
if (chars[i] >= '0' && chars[i] <= '9') {
if (isJava6 && hasLeadingPlusSign && !hasDecPoint) {
if (SystemUtils.IS_JAVA_1_6 && hasLeadingPlusSign && !hasDecPoint) {
return false;
}
// no type qualifier, OK

View File

@ -28,6 +28,7 @@
import java.math.BigInteger;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Test;
/**
@ -1298,7 +1299,7 @@ public void testLANG972() {
@Test
public void testLANG1252() {
//Check idiosyncries between java 1.6 and 1.7,1.8 redarding leading + signs
if (StringUtils.startsWith(System.getProperty("java.version"), "1.6")) {
if (SystemUtils.IS_JAVA_1_6) {
compareIsCreatableWithCreateNumber("+2", false);
} else {
compareIsCreatableWithCreateNumber("+2", true);