Fix potential null pointer error

java8
deannagarcia 2 years ago committed by GitHub
parent 075677e415
commit ae97c826f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      java/internal/JavaVersionTest.java

@ -40,12 +40,12 @@ public class JavaVersionTest {
@Test @Test
public void testJavaVersion() throws Exception { public void testJavaVersion() throws Exception {
String exp = System.getenv("KOKORO_JAVA_VERSION"); String exp = System.getenv("KOKORO_JAVA_VERSION");
// Java 8's version is read as "1.8"
if(exp.equals("8")) exp = "1.8";
if(exp == null || exp.isEmpty()) { if(exp == null || exp.isEmpty()) {
System.err.println("No kokoro java version found, skipping check"); System.err.println("No kokoro java version found, skipping check");
return; return;
} }
// Java 8's version is read as "1.8"
if(exp.equals("8")) exp = "1.8";
String version = System.getProperty("java.version"); String version = System.getProperty("java.version");
assertWithMessage("Expected Java " + exp + " but found Java " + version) assertWithMessage("Expected Java " + exp + " but found Java " + version)
.that(version.startsWith(exp)) .that(version.startsWith(exp))

Loading…
Cancel
Save