Fixed FELIX-3965 threads configuration status generates invalid results
https://issues.apache.org/jira/browse/FELIX-3965
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1455119 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java
index 5e3024e..ca3cf04 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java
@@ -25,7 +25,9 @@
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Comparator;
+import java.util.HashSet;
/**
* This is a helper class for dumping thread stacks.
@@ -78,7 +80,9 @@
printSummary(pw, rootGroup, groups);
printThreadGroup(pw, rootGroup, withStackTrace);
- for (int i = 0; i < numGroups; i++)
+ // don't use numGroups, but groups.length, otherwise when we get null elements
+ // sorted at the beginning, we will skip the real objects
+ for (int i = 0; i < groups.length; i++)
{
printThreadGroup(pw, groups[i], withStackTrace);
}
@@ -223,6 +227,9 @@
ArrayList/*<ThreadGroup>*/list = new ArrayList(groups.length + 1);
list.add(rootGroup);
list.addAll(Arrays.asList(groups));
+ // main group will eventually enumerate ALL threads, so don't
+ // count a thread, it if is already processed
+ Collection threadSet = new HashSet();
for (int j = 0; j < list.size(); j++)
{
ThreadGroup group = (ThreadGroup) list.get(j);
@@ -241,7 +248,7 @@
for (int i = 0, size = threads.length; i < size; i++)
{
Thread thread = threads[i];
- if (null != thread)
+ if (null != thread && threadSet.add(thread))
{
if (thread.isAlive())
{