Skip to content
Snippets Groups Projects
Commit 6d7a6e13 authored by SendaoYan's avatar SendaoYan
Browse files

8207908: JMXStatusTest.java fails assertion intermittently

Backport-of: d0abff2f0745aa135cc9dbf6def4f260b634f107
parent 8989babe
Branches
No related tags found
No related merge requests found
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -88,8 +88,6 @@ abstract public class JMXStatusTest { ...@@ -88,8 +88,6 @@ abstract public class JMXStatusTest {
args.addAll(getCustomVmArgs()); args.addAll(getCustomVmArgs());
args.add(TEST_APP_NAME); args.add(TEST_APP_NAME);
testAppPb = ProcessTools.createTestJavaProcessBuilder(args); testAppPb = ProcessTools.createTestJavaProcessBuilder(args);
jcmd = new ManagementAgentJcmd(TEST_APP_NAME, false);
} }
@BeforeMethod @BeforeMethod
...@@ -98,6 +96,7 @@ abstract public class JMXStatusTest { ...@@ -98,6 +96,7 @@ abstract public class JMXStatusTest {
TEST_APP_NAME, testAppPb, TEST_APP_NAME, testAppPb,
(Predicate<String>)l->l.trim().equals("main enter") (Predicate<String>)l->l.trim().equals("main enter")
); );
jcmd = new ManagementAgentJcmd(testApp, false);
} }
@AfterMethod @AfterMethod
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -47,11 +47,11 @@ final class ManagementAgentJcmd { ...@@ -47,11 +47,11 @@ final class ManagementAgentJcmd {
private static final String CMD_STATUS = "ManagementAgent.status"; private static final String CMD_STATUS = "ManagementAgent.status";
private static final String CMD_PRINTPERF = "PerfCounter.print"; private static final String CMD_PRINTPERF = "PerfCounter.print";
private final String id; private final long pid;
private final boolean verbose; private final boolean verbose;
public ManagementAgentJcmd(String targetApp, boolean verbose) { public ManagementAgentJcmd(Process targetApp, boolean verbose) {
this.id = targetApp; this.pid = targetApp.pid();
this.verbose = verbose; this.verbose = verbose;
} }
...@@ -174,7 +174,7 @@ final class ManagementAgentJcmd { ...@@ -174,7 +174,7 @@ final class ManagementAgentJcmd {
* @throws InterruptedException * @throws InterruptedException
*/ */
private String jcmd(Consumer<String> c, String ... command) throws IOException, InterruptedException { private String jcmd(Consumer<String> c, String ... command) throws IOException, InterruptedException {
return jcmd(id, c, command); return jcmd(Long.toString(pid), c, command);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment