From 5a0943805f7ef3da691bd4f39660346bfc7283d6 Mon Sep 17 00:00:00 2001 From: "Javier A. Ortiz Bultron" Date: Fri, 13 Oct 2023 09:59:38 -0500 Subject: [PATCH] [SUREFIRE-2202] NullPointerException if super class meets specific condition This closes #673 --- .../apache/maven/surefire/testng/utils/MethodSelector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java index 42bb4fae03..b5930ad4ef 100644 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java +++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java @@ -61,7 +61,9 @@ private static boolean shouldRun(ITestNGMethod test) { boolean hasTestResolver = resolver != null && !resolver.isEmpty(); if (hasTestResolver) { boolean run = false; - for (Class clazz = test.getRealClass(); !run && clazz != Object.class; clazz = clazz.getSuperclass()) { + for (Class clazz = test.getRealClass(); + !run && clazz != null && clazz != Object.class; + clazz = clazz.getSuperclass()) { run = resolver.shouldRun(clazz, test.getMethodName()); } return run;