From 52d71829e2e165830439fab6be9291b2fb40fbc3 Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Wed, 22 Jul 2026 17:09:46 +0300 Subject: [PATCH] Remove always-false array-length check in ForgeRockTestListener checkForInterleavedBetweenClasses wrapped a single ITestNGMethod.getInstance() value into a one-element array and then tested testInstances.length != 1, a condition that is always false (dead branch flagged by CodeQL java/constant-comparison). Use the single test instance directly and drop the useless array allocation and comparison. --- .../java/org/forgerock/testng/ForgeRockTestListener.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build-tools/src/main/java/org/forgerock/testng/ForgeRockTestListener.java b/build-tools/src/main/java/org/forgerock/testng/ForgeRockTestListener.java index 5d2942159..ae4235345 100755 --- a/build-tools/src/main/java/org/forgerock/testng/ForgeRockTestListener.java +++ b/build-tools/src/main/java/org/forgerock/testng/ForgeRockTestListener.java @@ -449,14 +449,7 @@ private void addTestResult(final ITestResult result) { } private void checkForInterleavedBetweenClasses(final ITestResult tr) { - final Object[] testInstances = new Object[] { tr.getMethod().getInstance() }; - // This will almost always have a single element. If it doesn't, - // just skip it. - if (testInstances.length != 1) { - return; - } - - final Object testInstance = testInstances[0]; + final Object testInstance = tr.getMethod().getInstance(); // We're running another test on the same test object. Everything is // fine.