Use Objects.equals() for null-safe string comparison

See gh-31305
This commit is contained in:
ali dandach
2023-09-24 23:53:04 +03:00
committed by Stéphane Nicoll
parent bc3d98565c
commit 1d12c74042
3 changed files with 3 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
@@ -179,7 +180,7 @@ public class SpringExtension implements BeforeAllCallback, AfterAllCallback, Tes
testClass.getName(), Arrays.toString(methodsWithErrors)));
}, String.class);
if (errorMessage != NO_VIOLATIONS_DETECTED) {
if (!Objects.equals(errorMessage, NO_VIOLATIONS_DETECTED)) {
throw new IllegalStateException(errorMessage);
}
}
@@ -218,7 +219,7 @@ public class SpringExtension implements BeforeAllCallback, AfterAllCallback, Tes
published by other tests since the application context may be shared.""";
}, String.class);
if (errorMessage != NO_VIOLATIONS_DETECTED) {
if (!Objects.equals(errorMessage, NO_VIOLATIONS_DETECTED)) {
throw new IllegalStateException(errorMessage);
}
}