From ec4846d8a848165654a1d642f8e59da0c5890494 Mon Sep 17 00:00:00 2001 From: Scott M Stark Date: Mon, 7 Oct 2024 01:54:37 -0600 Subject: [PATCH] Meke check for a VehicleClient instance more robust to not cause CNFEs. Signed-off-by: Scott M Stark #1562 --- .../java/com/sun/ts/lib/harness/ServiceEETest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java b/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java index 93f9b26e27..01623bc87c 100644 --- a/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java +++ b/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java @@ -87,7 +87,18 @@ public Properties getVehicleSpecificClientProps(Properties p) { public Status run(String[] argv, Properties p) { Status status = null; boolean inTestHarness = TestUtil.iWhereAreWe == TestUtil.VM_HARNESS; - boolean isVehicleClient = this instanceof com.sun.ts.tests.common.vehicle.VehicleClient; + boolean isVehicleClient = false; + URL thisURL = getClass().getProtectionDomain().getCodeSource().getLocation(); + TestUtil.logTrace("in ServiceEETest.run(), this URL is: " + thisURL); + try { + Class vcClass = getClass().getClassLoader().loadClass("com.sun.ts.tests.common.vehicle.VehicleClient"); + URL vcClassURL = vcClass.getProtectionDomain().getCodeSource().getLocation(); + TestUtil.logTrace("VehicleClient URL is: " + vcClassURL); + isVehicleClient = vcClass.isAssignableFrom(getClass()); + TestUtil.logTrace("VehicleClient URL is: " + vcClassURL); + } catch (ClassNotFoundException e) { + TestUtil.logTrace("VehicleClient class not found, so not a vehicle client."); + } if (inTestHarness && isVehicleClient) { TestUtil.logTrace("in ServiceEETest.run() method"); String sVehicle = TestUtil.getProperty(p, "vehicle");