[hornetq-commits] JBoss hornetq SVN: r11123 - in branches/Branch_2_2_EAP_cluster_clean2: tests/src/org/hornetq/tests/integration/cluster/distribution and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Aug 4 16:32:16 EDT 2011


Author: clebert.suconic at jboss.com
Date: 2011-08-04 16:32:15 -0400 (Thu, 04 Aug 2011)
New Revision: 11123

Modified:
   branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
   branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
   branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
tweak

Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java	2011-08-04 15:30:21 UTC (rev 11122)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java	2011-08-04 20:32:15 UTC (rev 11123)
@@ -1404,20 +1404,6 @@
       }
    }
 
-   public static void shutdown()
-   {
-      if (globalScheduledThreadPool != null)
-      {
-         globalScheduledThreadPool.shutdown();
-         globalScheduledThreadPool = null;
-      }
-      if (globalThreadPool != null)
-      {
-         globalThreadPool.shutdown();
-         globalThreadPool = null;
-      }
-   }
-
    class StaticConnector implements Serializable
    {
       private static final long serialVersionUID = 6772279632415242634l;

Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java	2011-08-04 15:30:21 UTC (rev 11122)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java	2011-08-04 20:32:15 UTC (rev 11123)
@@ -111,6 +111,9 @@
       }
 
       locators = new ServerLocator[ClusterTestBase.MAX_SERVERS];
+      
+      // To make sure the test will start with a clean VM
+      forceGC();
 
    }
 
@@ -148,8 +151,6 @@
       nodeManagers = null;
 
       super.tearDown();
-
-    //  ServerLocatorImpl.shutdown();
    }
 
    // Private -------------------------------------------------------------------------------------------------------

Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java	2011-08-04 15:30:21 UTC (rev 11122)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java	2011-08-04 20:32:15 UTC (rev 11123)
@@ -259,6 +259,7 @@
 
    public static void forceGC()
    {
+      log.info("#test forceGC");
       WeakReference<Object> dumbReference = new WeakReference<Object>(new Object());
       // A loop that will wait GC, using the minimal time as possible
       while (dumbReference.get() != null)
@@ -266,12 +267,13 @@
          System.gc();
          try
          {
-            Thread.sleep(500);
+            Thread.sleep(100);
          }
          catch (InterruptedException e)
          {
          }
       }
+      log.info("#test forceGC Done");
    }
 
    public static void forceGC(Reference<?> ref, long timeout)
@@ -930,13 +932,49 @@
          }
       }
 
+      
+      
+      StringBuffer buffer = null;
+      
+      boolean failed =  true;
+      
+      long timeout = System.currentTimeMillis() + 10000;
+      while (failed && timeout > System.currentTimeMillis())
+      {
+         buffer = new StringBuffer();
+         
+         failed = checkThread(buffer);
+         
+         if (failed)
+         {
+            forceGC();
+            Thread.sleep(500);
+            log.info("There are still threads running, trying again");
+         }
+      }
+      
+      if (failed)
+      {
+         logAndSystemOut("Thread leaged on test " + this.getClass().getName() + "::" + 
+                         this.getName() + "\n" + buffer.toString());
+         fail("Thread leakage");
+      }
+
+      super.tearDown();
+   }
+
+   /**
+    * @param buffer
+    * @return
+    */
+   private boolean checkThread(StringBuffer buffer)
+   {
+      boolean failedThread = false;
+
       Map<Thread, StackTraceElement[]> postThreads = Thread.getAllStackTraces();
 
-      boolean failedThread = false;
       if (postThreads.size() > previousThreads.size())
       {
-         StringBuffer buffer = new StringBuffer();
-
          
          buffer.append("*********************************************************************************\n");
          buffer.append("LEAKING THREADS\n");
@@ -958,13 +996,8 @@
          }
          buffer.append("*********************************************************************************\n");
 
-         System.out.println(buffer.toString());
-
       }
-      
-      //assertFalse("Thread Failed", failedThread);
-
-      super.tearDown();
+      return failedThread;
    }
 
    /**



More information about the hornetq-commits mailing list