Skip to content

Commit 32de66c

Browse files
committed
Do not use endsWith on path for string comparison
1 parent 45ea1b9 commit 32de66c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ public static Path getAppClassLocation(Class<?> testClass) {
178178
* @return directory or JAR containing the application being tested by a test from the given location
179179
*/
180180
public static Path getAppClassLocationForTestLocation(Path testClassLocationPath) {
181-
if (testClassLocationPath.endsWith(".jar")) {
182-
if (testClassLocationPath.endsWith("-tests.jar")) {
183-
String testClassLocation = testClassLocationPath.toString();
181+
String testClassLocation = testClassLocationPath.toString();
182+
183+
if (testClassLocation.endsWith(".jar")) {
184+
if (testClassLocation.endsWith("-tests.jar")) {
184185
return Paths.get(new StringBuilder()
185186
.append(testClassLocation, 0, testClassLocation.length() - "-tests.jar".length())
186187
.append(".jar")
187188
.toString());
188189
}
189190
return testClassLocationPath;
190191
}
191-
String testClassLocation = testClassLocationPath.toString();
192192
Optional<Path> mainClassesDir = TEST_TO_MAIN_DIR_FRAGMENTS.entrySet().stream()
193193
.filter(e -> testClassLocation.contains(e.getKey()))
194194
.map(e -> {
@@ -211,7 +211,7 @@ public static Path getAppClassLocationForTestLocation(Path testClassLocationPath
211211
}
212212
// could be a custom test classes dir under the 'target' dir with the main
213213
// classes still under 'target/classes'
214-
p = Path.of(testClassLocation).getParent();
214+
p = testClassLocationPath.getParent();
215215
if (p != null && p.getFileName().toString().equals(TARGET)) {
216216
p = p.resolve("classes");
217217
if (Files.exists(p)) {

0 commit comments

Comments
 (0)