Skip to content

Commit

Permalink
8081652: [TESTBUG] java/lang/management/ThreadMXBean/ThreadMXBeanStat…
Browse files Browse the repository at this point in the history
…eTest.java timed out intermittently

Reviewed-by: mdoerr
Backport-of: 5805cbe
  • Loading branch information
GoeLin committed Sep 28, 2021
1 parent 1476158 commit b433235
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -547,7 +547,6 @@ java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-a
java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all
java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all

java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java 8081652 generic-all
java/lang/management/ThreadMXBean/AllThreadIds.java 8131745 generic-all

############################################################################
Expand Down
13 changes: 11 additions & 2 deletions test/jdk/java/lang/Thread/ThreadStateController.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
Expand Down Expand Up @@ -359,7 +359,16 @@ private void log(String msg, Object ... params) {
* @throws InterruptedException
*/
public String getLog() throws InterruptedException {
this.join();
return getLog(0);
}

/**
* Waits at most {@code millis} milliseconds for the controller
* to complete the test run and returns the generated log.
* A timeout of {@code 0} means to wait forever.
*/
public String getLog(long millis) throws InterruptedException {
this.join(millis);

return logger.toString();
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -38,6 +38,8 @@
* @run main ThreadMXBeanStateTest
*/

import jdk.test.lib.Utils;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.lang.management.ThreadInfo;
Expand Down Expand Up @@ -114,7 +116,7 @@ public static void main(String[] argv) throws Exception {
thread.checkThreadState(TERMINATED);
} finally {
try {
System.out.println(thread.getLog());
System.out.println(thread.getLog(Utils.adjustTimeout(60_000)));
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("TEST FAILED: Unexpected exception.");
Expand Down

1 comment on commit b433235

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.