RFR: 8287008: Improve tests for thread dumps in JSON format [v3]

Chris Plummer cjplummer at openjdk.java.net
Mon May 23 06:17:48 UTC 2022


On Fri, 20 May 2022 16:41:36 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> This is a test-only change to add some test infrastructure and improve the testing of thread dumps in JSON format. The new tests added by JEP 425 for this thread dump format search the JSON text for strings but don't parse it completely.  These tests can be improved with a test class that parses the thread dump. The tests for JEP 428 like make use of the test infrastructure too.
>
> Alan Bateman has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove spurious colon

test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java line 115:

> 113: 
> 114:                 // find the thread container that corresponds to the executor
> 115:                 String name = Objects.toIdentityString(executor);

I don't understand the need for `toIdentityString()` rather than just `toString()`

test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java line 121:

> 119:                 container.findThread(vthread.threadId()).orElseThrow();
> 120: 
> 121:                 // if the current thread is a platform thread then will be in root container

"..._it_ will be in _the_ root container"

test/lib/jdk/test/lib/threaddump/ThreadDump.java line 179:

> 177:                 return this;
> 178:             if (name().startsWith(name + "/"))
> 179:                 return this;

It's not clear to me why this is here. What does it mean if the name of the container starts with `<name>/`?

test/lib/jdk/test/lib/threaddump/ThreadDump.java line 299:

> 297: 
> 298:             // add to map if not already encountered
> 299:             var container = map.computeIfAbsent(name, k -> new ThreadContainer(name));

Why might the container already be in `map`?

-------------

PR: https://git.openjdk.java.net/jdk/pull/8784


More information about the serviceability-dev mailing list