@@ -88,16 +88,22 @@ public class ScenarioReporter implements ConcurrentEventListener {
8888 private static final String TEST_CASE_ID_PREFIX = "@tc_id:" ;
8989 private static final String ERROR_FORMAT = "Error:\n %s" ;
9090
91- private static final Class <?> TESTNG_LISTENER_CLASS ;
91+ private static final Method IS_RETRY_METHOD ;
9292
9393 static {
9494 Class <?> testNgListenerClass = null ;
9595 try {
9696 testNgListenerClass = Class .forName ("com.epam.reportportal.cucumber.testng.TestNgRetriesListener" );
9797 } catch (Exception ignore ) {
98-
9998 }
100- TESTNG_LISTENER_CLASS = testNgListenerClass ;
99+ Method isRetry = null ;
100+ if (testNgListenerClass != null ) {
101+ try {
102+ isRetry = testNgListenerClass .getMethod ("isRetry" , String .class );
103+ } catch (NoSuchMethodException ignore ) {
104+ }
105+ }
106+ IS_RETRY_METHOD = isRetry ;
101107 }
102108
103109 private final Map <URI , FeatureContext > featureContextMap = new ConcurrentHashMap <>();
@@ -1011,14 +1017,13 @@ protected void beforeScenario(@Nonnull TestCase scenario) {
10111017 // If it's a ScenarioOutline use Example's line number as code reference to detach one Test Item from another
10121018 StartTestItemRQ startTestItemRQ = buildStartScenarioRequest (scenario );
10131019 boolean testNgRetry = false ;
1014- if (TESTNG_LISTENER_CLASS != null ) {
1020+ if (IS_RETRY_METHOD != null ) {
10151021 try {
1016- Method isRetry = TESTNG_LISTENER_CLASS .getMethod ("isRetry" , String .class );
1017- testNgRetry = (Boolean ) isRetry .invoke (
1022+ testNgRetry = Boolean .TRUE .equals (IS_RETRY_METHOD .invoke (
10181023 null ,
10191024 scenario .getUri () + KEY_VALUE_SEPARATOR + scenario .getLocation ().getLine ()
1020- );
1021- } catch (NoSuchMethodException | SecurityException | InvocationTargetException | IllegalAccessException ignore ) {
1025+ )) ;
1026+ } catch (SecurityException | InvocationTargetException | IllegalAccessException ignore ) {
10221027 }
10231028 }
10241029 if (testNgRetry ) {
0 commit comments