mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-02-28 14:29:31 +00:00
ARTEMIS-3854: use Process.pid() rather than reflection
This commit is contained in:
parent
0fab0dae91
commit
0c5e83b76a
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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" +
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user