Skip to content

Commit

Permalink
[Wisp] WispThreadCompositeData.getCompositeData() should use legal Th…
Browse files Browse the repository at this point in the history
…read State String.

Summary: sun.management.ThreadInfoCompositeData.threadState() will use valueOf() to read Thread.State String. We should specify a TERMINATED String for it. Also, a cleanup.

Test Plan: com/alibaba/wisp/thread/TestThreadInfo.java

Reviewed-by: yulei

Issue:
dragonwell-project#155
  • Loading branch information
ZhaiMo15 committed Sep 15, 2023
1 parent fb50f20 commit 422176a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package sun.management;

import com.alibaba.wisp.engine.WispEngine;
import com.alibaba.wisp.engine.WispTask;
import jdk.internal.access.SharedSecrets;
import jdk.internal.access.WispEngineAccess;

Expand Down Expand Up @@ -206,7 +207,11 @@ public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
if (WispEngine.enableThreadAsWisp()) {
for (int i = 0; i < infos.length; i++) {
if (infos[i] == null) {
infos[i] = ThreadInfo.from(new WispThreadCompositeData(WEA.getWispTaskById(ids[i])));
WispTask task = WEA.getWispTaskById(ids[i]);
if (task == null) {
continue;
}
infos[i] = ThreadInfo.from(new WispThreadCompositeData(task));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ public class WispThreadCompositeData extends LazyCompositeData {
private final WispTask task;

public WispThreadCompositeData(WispTask wispTask) {
assert wispTask != null : "handled null cases already";
task = wispTask;
}

@Override
protected CompositeData getCompositeData() {
Map<String, Object> items = new HashMap<>();
Thread t = task != null ? task.getThreadWrapper() : null;
Thread t = task.getThreadWrapper();
Object parkBlocker = t != null ? LockSupport.getBlocker(t) : null;
items.put(THREAD_ID, t != null ? t.getId() : 0L);
items.put(THREAD_NAME, t != null ? t.getName() : "");
items.put(THREAD_STATE, t != null ? t.getState().name() : "");
items.put(THREAD_STATE, t != null ? t.getState().name() : Thread.State.TERMINATED.toString());
items.put(LOCK_NAME, parkBlocker == null ? "" : parkBlocker.toString());
items.put(BLOCKED_TIME, 0L);
items.put(BLOCKED_COUNT, 0L);
Expand Down

0 comments on commit 422176a

Please sign in to comment.