8207908: JMXStatusTest.java fails assertion intermittently

Backport-of: b7d0eff5ad
This commit is contained in:
SendaoYan
2024-11-15 09:33:40 +00:00
committed by Vitaly Provodin
parent 204ebc1f01
commit 90aaf660b1
2 changed files with 7 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,8 +88,6 @@ abstract public class JMXStatusTest {
args.addAll(getCustomVmArgs());
args.add(TEST_APP_NAME);
testAppPb = ProcessTools.createTestJavaProcessBuilder(args);
jcmd = new ManagementAgentJcmd(TEST_APP_NAME, false);
}
@BeforeMethod
@@ -98,6 +96,7 @@ abstract public class JMXStatusTest {
TEST_APP_NAME, testAppPb,
(Predicate<String>)l->l.trim().equals("main enter")
);
jcmd = new ManagementAgentJcmd(testApp, false);
}
@AfterMethod

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,11 +47,11 @@ final class ManagementAgentJcmd {
private static final String CMD_STATUS = "ManagementAgent.status";
private static final String CMD_PRINTPERF = "PerfCounter.print";
private final String id;
private final long pid;
private final boolean verbose;
public ManagementAgentJcmd(String targetApp, boolean verbose) {
this.id = targetApp;
public ManagementAgentJcmd(Process targetApp, boolean verbose) {
this.pid = targetApp.pid();
this.verbose = verbose;
}
@@ -174,7 +174,7 @@ final class ManagementAgentJcmd {
* @throws InterruptedException
*/
private String jcmd(Consumer<String> c, String ... command) throws IOException, InterruptedException {
return jcmd(id, c, command);
return jcmd(Long.toString(pid), c, command);
}
/**