diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ExecuteUtil.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ExecuteUtil.java index 921b5ab82d..14456c87ef 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ExecuteUtil.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ExecuteUtil.java @@ -39,8 +39,8 @@ public class ExecuteUtil { inputStreamReader.join(); } - public int pid() throws Exception { - return getPID(process); + public long pid() throws Exception { + return process.pid(); } public int waitFor(long timeout, TimeUnit unit) throws InterruptedException { @@ -66,12 +66,6 @@ public class ExecuteUtil { } - public static int getPID(Process process) throws Exception { - Field pidField = process.getClass().getDeclaredField("pid"); - pidField.setAccessible(true); - return (int)pidField.get(process); - } - private static final Logger logger = Logger.getLogger(ExecuteUtil.class); public static int runCommand(boolean logOutput, String... command) throws Exception { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPBridgeDisconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPBridgeDisconnectTest.java index 2123aae169..606a8228e3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPBridgeDisconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPBridgeDisconnectTest.java @@ -134,8 +134,8 @@ public class AMQPBridgeDisconnectTest extends AmqpClientTestSupport { return this.server.getRemotingService().getConnections().size(); }); if (pause) { - int pid = ExecuteUtil.getPID(process); - ExecuteUtil.runCommand(true, new String[]{"kill", "-STOP", Integer.toString(pid)}); + long pid = process.pid(); + ExecuteUtil.runCommand(true, new String[]{"kill", "-STOP", Long.toString(pid)}); } else { process.destroy(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java index 6e39d63275..fc8630b365 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java @@ -85,7 +85,7 @@ public class QpidDispatchPeerTest extends AmqpClientTestSupport { } public void pauseThenKill(int timeToWait) throws Exception { - int pid = qpidProcess.pid(); + long pid = qpidProcess.pid(); int result = ExecuteUtil.runCommand(true, "kill", "-STOP", Long.toString(pid)); Assert.assertEquals(0, result); logger.info("\n*******************************************************************************************************************************\n" + diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/SoakPagingTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/SoakPagingTest.java index 2294d45253..f37fb374a9 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/SoakPagingTest.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/SoakPagingTest.java @@ -227,7 +227,7 @@ public class SoakPagingTest extends SmokeTestBase { System.out.println("*******************************************************************************************************************************"); System.out.println("SERVER 0 jstack"); System.out.println("*******************************************************************************************************************************"); - ExecuteUtil.runCommand(true, 1, TimeUnit.MINUTES, "jstack", "" + ExecuteUtil.getPID(server0)); + ExecuteUtil.runCommand(true, 1, TimeUnit.MINUTES, "jstack", "" + server0.pid()); } catch (Throwable e) { log.warn("Error executing jstack on Server 0", e); } @@ -235,7 +235,7 @@ public class SoakPagingTest extends SmokeTestBase { System.out.println("*******************************************************************************************************************************"); System.out.println("SERVER 1 jstack"); System.out.println("*******************************************************************************************************************************"); - ExecuteUtil.runCommand(true, 1, TimeUnit.MINUTES, "jstack", "" + ExecuteUtil.getPID(server1)); + ExecuteUtil.runCommand(true, 1, TimeUnit.MINUTES, "jstack", "" + server1.pid()); } catch (Throwable e) { log.warn("Error executing jstack on Server 1", e); }