You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by vv...@apache.org on 2013/03/21 16:08:41 UTC

svn commit: r1459347 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java

Author: vvalchev
Date: Thu Mar 21 15:08:41 2013
New Revision: 1459347

URL: http://svn.apache.org/r1459347
Log:
Fixed FELIX-3986 ThreadDumper comparators are not correctly implemented
https://issues.apache.org/jira/browse/FELIX-3986

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java?rev=1459347&r1=1459346&r2=1459347&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java Thu Mar 21 15:08:41 2013
@@ -348,8 +348,19 @@ final class ThreadComparator implements 
 
     public int compare(Object thread1, Object thread2)
     {
-        if (null == thread1 || null == thread2)
-            return -1;
+        if (thread1 == null && thread2 == null)
+        {
+            return 0;
+        }
+        if (thread1 == null)
+        {
+            return 1; // null is always >, moves nulls at the end
+        }
+        if (thread2 == null)
+        {
+            return -1; // first is always < than null, moves nulls at the end 
+        }
+
         String t1 = ((Thread) thread1).getName();
         String t2 = ((Thread) thread2).getName();
         if (null == t1)
@@ -383,8 +394,19 @@ final class ThreadGroupComparator implem
 
     public int compare(Object thread1, Object thread2)
     {
-        if (null == thread1 || null == thread2)
-            return -1;
+        if (thread1 == null && thread2 == null)
+        {
+            return 0;
+        }
+        if (thread1 == null)
+        {
+            return 1; // null is always >, moves nulls at the end
+        }
+        if (thread2 == null)
+        {
+            return -1; // first is always < than null, moves nulls at the end 
+        }
+
         String t1 = ((ThreadGroup) thread1).getName();
         String t2 = ((ThreadGroup) thread2).getName();
         if (null == t1)