Better fix for java8 restriction of g1gc check
This makes the fix actually testable.
This commit is contained in:
parent
562a30d3c6
commit
6b4280c7be
|
@ -559,7 +559,7 @@ final class BootstrapCheck {
|
|||
|
||||
@Override
|
||||
public boolean check() {
|
||||
if ("Oracle Corporation".equals(jvmVendor()) && Constants.JRE_IS_MINIMUM_JAVA9 == false && isG1GCEnabled()) {
|
||||
if ("Oracle Corporation".equals(jvmVendor()) && isJava8() && isG1GCEnabled()) {
|
||||
final String jvmVersion = jvmVersion();
|
||||
final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)-b\\d+");
|
||||
final Matcher matcher = pattern.matcher(jvmVersion);
|
||||
|
@ -590,6 +590,11 @@ final class BootstrapCheck {
|
|||
return Constants.JVM_VERSION;
|
||||
}
|
||||
|
||||
// visible for tests
|
||||
boolean isJava8() {
|
||||
return Constants.JVM_SPEC_VERSION.equals("1.8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String errorMessage() {
|
||||
return String.format(
|
||||
|
|
|
@ -534,6 +534,7 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
|
||||
public void testG1GCCheck() throws NodeValidationException {
|
||||
final AtomicBoolean isG1GCEnabled = new AtomicBoolean(true);
|
||||
final AtomicBoolean isJava8 = new AtomicBoolean(true);
|
||||
final AtomicReference<String> jvmVersion =
|
||||
new AtomicReference<>(String.format(Locale.ROOT, "25.%d-b%d", randomIntBetween(0, 39), randomIntBetween(1, 128)));
|
||||
final BootstrapCheck.G1GCCheck oracleCheck = new BootstrapCheck.G1GCCheck() {
|
||||
|
@ -553,6 +554,11 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
return jvmVersion.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isJava8() {
|
||||
return isJava8.get();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
final NodeValidationException e =
|
||||
|
@ -584,6 +590,15 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
|
||||
// if not on an Oracle JVM, nothing should happen
|
||||
BootstrapCheck.check(true, Collections.singletonList(nonOracleCheck), "testG1GCCheck");
|
||||
|
||||
final BootstrapCheck.G1GCCheck nonJava8Check = new BootstrapCheck.G1GCCheck() {
|
||||
@Override
|
||||
boolean isJava8() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// if not java 8, nothing should happen
|
||||
BootstrapCheck.check(true, Collections.singletonList(nonJava8Check), "testG1GCCheck");
|
||||
}
|
||||
|
||||
public void testAlwaysEnforcedChecks() {
|
||||
|
|
Loading…
Reference in New Issue