Skip to content

Commit 8b70f6f

Browse files
authored
Merge pull request #2817 from krmahadevan/fix_2308
2 parents 8ecef60 + 3b84427 commit 8b70f6f

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Current
2+
Fixed: GITHUB-2308: StringIndexOutOfBoundsException in findClassesInPackage - Surefire/Maven - JDK 11 fails (Krishnan Mahadevan)
23
Fixed: GITHUB:2788: TestResult.isSuccess() is TRUE when test fails due to expectedExceptions (Krishnan Mahadevan)
34
Fixed: GITHUB-2800: Running Test Classes with Inherited @Factory and @DataProvider Annotated Non-Static Methods Fail (Krishnan Mahadevan)
45
New: Ability to provide custom error message for assertThrows\expectThrows methods (Anatolii Yuzhakov)

testng-core-api/src/main/java/org/testng/internal/PackageUtils.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.testng.internal;
22

3+
import static java.nio.charset.StandardCharsets.UTF_8;
4+
35
import java.io.File;
46
import java.io.IOException;
5-
import java.io.UnsupportedEncodingException;
67
import java.lang.reflect.Method;
78
import java.net.JarURLConnection;
89
import java.net.URL;
@@ -25,7 +26,6 @@
2526
* @author <a href="mailto:[email protected]">Cedric Beust</a>
2627
*/
2728
public class PackageUtils {
28-
private static final String UTF_8 = "UTF-8";
2929
private static final String PACKAGE_UTILS = PackageUtils.class.getSimpleName();
3030
private static String[] testClassPaths;
3131

@@ -36,11 +36,6 @@ private PackageUtils() {
3636
// Utility class. Defeat instantiation.
3737
}
3838

39-
/** Add a class loader to the searchable loaders. */
40-
public static void addClassLoader(final ClassLoader loader) {
41-
classLoaders.add(loader);
42-
}
43-
4439
/**
4540
* @param packageName - The package name
4641
* @param included - The inclusion list.
@@ -96,6 +91,9 @@ public static String[] findClassesInPackage(
9691
while (entries.hasMoreElements()) {
9792
JarEntry entry = entries.nextElement();
9893
String name = entry.getName();
94+
if (name.startsWith("module-info") || name.startsWith("META-INF")) {
95+
continue;
96+
}
9997
if (name.charAt(0) == '/') {
10098
name = name.substring(1);
10199
}
@@ -183,11 +181,7 @@ private static boolean matchTestClasspath(URL url, String lastFragment, boolean
183181
}
184182

185183
String fileName = "";
186-
try {
187-
fileName = URLDecoder.decode(url.getFile(), UTF_8);
188-
} catch (UnsupportedEncodingException ueex) {
189-
// ignore. should never happen
190-
}
184+
fileName = URLDecoder.decode(url.getFile(), UTF_8);
191185

192186
for (String classpathFrag : classpathFragments) {
193187
String path = classpathFrag + lastFragment;

0 commit comments

Comments
 (0)