From a1ca298bc1c57271b60014ffa98178290014d4e4 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <23113631+pixeebot@users.noreply.github.com> Date: Sat, 7 Oct 2023 09:17:12 +0000 Subject: [PATCH] Switch order of literals to prevent NullPointerException --- .../java/org/junit/platform/commons/util/CloseablePath.java | 2 +- .../src/main/java/org/junit/platform/engine/UniqueId.java | 2 +- .../org/junit/platform/launcher/core/EngineIdValidator.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/CloseablePath.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/CloseablePath.java index 58ad17ce39c7..3f7af1ddd407 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/CloseablePath.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/CloseablePath.java @@ -59,7 +59,7 @@ static CloseablePath create(URI uri, FileSystemProvider fileSystemProvider) thro return createForJarFileSystem(new URI(jarUri), fileSystem -> fileSystem.getPath(jarEntry), fileSystemProvider); } - if (uri.getScheme().equals(FILE_URI_SCHEME) && uri.getPath().endsWith(JAR_FILE_EXTENSION)) { + if (FILE_URI_SCHEME.equals(uri.getScheme()) && uri.getPath().endsWith(JAR_FILE_EXTENSION)) { return createForJarFileSystem(new URI(JAR_URI_SCHEME + ':' + uri), fileSystem -> fileSystem.getRootDirectories().iterator().next(), fileSystemProvider); } diff --git a/junit-platform-engine/src/main/java/org/junit/platform/engine/UniqueId.java b/junit-platform-engine/src/main/java/org/junit/platform/engine/UniqueId.java index 5e4f13b99661..f60e0db8b588 100644 --- a/junit-platform-engine/src/main/java/org/junit/platform/engine/UniqueId.java +++ b/junit-platform-engine/src/main/java/org/junit/platform/engine/UniqueId.java @@ -118,7 +118,7 @@ final Optional getRoot() { * @see #forEngine(String) */ public final Optional getEngineId() { - return getRoot().filter(segment -> segment.getType().equals(ENGINE_SEGMENT_TYPE)).map(Segment::getValue); + return getRoot().filter(segment -> ENGINE_SEGMENT_TYPE.equals(segment.getType())).map(Segment::getValue); } /** diff --git a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineIdValidator.java b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineIdValidator.java index abeeb298acaa..47e379b42bf0 100644 --- a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineIdValidator.java +++ b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineIdValidator.java @@ -56,15 +56,15 @@ private static boolean validateReservedIds(TestEngine testEngine) { if (!engineId.startsWith("junit-")) { return true; } - if (engineId.equals("junit-jupiter")) { + if ("junit-jupiter".equals(engineId)) { validateWellKnownClassName(testEngine, "org.junit.jupiter.engine.JupiterTestEngine"); return true; } - if (engineId.equals("junit-vintage")) { + if ("junit-vintage".equals(engineId)) { validateWellKnownClassName(testEngine, "org.junit.vintage.engine.VintageTestEngine"); return true; } - if (engineId.equals("junit-platform-suite")) { + if ("junit-platform-suite".equals(engineId)) { validateWellKnownClassName(testEngine, "org.junit.platform.suite.engine.SuiteTestEngine"); return true; }