Skip to content

Commit d0abff2

Browse files
author
SendaoYan
committed
8207908: JMXStatusTest.java fails assertion intermittently
Backport-of: b7d0eff5ad77e338b237773d2fc047eea3d2ac12
1 parent c5d75ef commit d0abff2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -88,8 +88,6 @@ public final void setup() throws Exception {
8888
args.addAll(getCustomVmArgs());
8989
args.add(TEST_APP_NAME);
9090
testAppPb = ProcessTools.createTestJavaProcessBuilder(args);
91-
92-
jcmd = new ManagementAgentJcmd(TEST_APP_NAME, false);
9391
}
9492

9593
@BeforeMethod
@@ -98,6 +96,7 @@ public final void startTestApp() throws Exception {
9896
TEST_APP_NAME, testAppPb,
9997
(Predicate<String>)l->l.trim().equals("main enter")
10098
);
99+
jcmd = new ManagementAgentJcmd(testApp, false);
101100
}
102101

103102
@AfterMethod

test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -47,11 +47,11 @@ final class ManagementAgentJcmd {
4747
private static final String CMD_STATUS = "ManagementAgent.status";
4848
private static final String CMD_PRINTPERF = "PerfCounter.print";
4949

50-
private final String id;
50+
private final long pid;
5151
private final boolean verbose;
5252

53-
public ManagementAgentJcmd(String targetApp, boolean verbose) {
54-
this.id = targetApp;
53+
public ManagementAgentJcmd(Process targetApp, boolean verbose) {
54+
this.pid = targetApp.pid();
5555
this.verbose = verbose;
5656
}
5757

@@ -174,7 +174,7 @@ private String jcmd(String ... command) throws IOException, InterruptedException
174174
* @throws InterruptedException
175175
*/
176176
private String jcmd(Consumer<String> c, String ... command) throws IOException, InterruptedException {
177-
return jcmd(id, c, command);
177+
return jcmd(Long.toString(pid), c, command);
178178
}
179179

180180
/**

0 commit comments

Comments
 (0)