Author: clebert.suconic(a)jboss.com
Date: 2011-08-04 19:34:24 -0400 (Thu, 04 Aug 2011)
New Revision: 11125
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/NettyAcceptor.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
fixing thread leakages on the testsuite
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java 2011-08-04
20:33:29 UTC (rev 11124)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java 2011-08-04
23:34:24 UTC (rev 11125)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.netty;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -45,7 +45,7 @@
private final BlockingQueue<Runnable> delayedResponses = new
LinkedBlockingQueue<Runnable>();
- private final Executor executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
delayedResponses);
+ private final ExecutorService executor = new ThreadPoolExecutor(1, 1, 0,
TimeUnit.SECONDS, delayedResponses);
private final HttpKeepAliveRunnable httpKeepAliveTask;
@@ -211,6 +211,19 @@
}
}
+
+
+ public void shutdown()
+ {
+ executor.shutdown();
+ try
+ {
+ executor.awaitTermination(10, TimeUnit.SECONDS);
+ }
+ catch (Exception e)
+ {
+ }
+ }
/**
* a holder class so we know what time the request first arrived
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/NettyAcceptor.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/NettyAcceptor.java 2011-08-04
20:33:29 UTC (rev 11124)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/remoting/impl/netty/NettyAcceptor.java 2011-08-04
23:34:24 UTC (rev 11125)
@@ -136,6 +136,8 @@
private final int nioRemotingThreads;
private final HttpKeepAliveRunnable httpKeepAliveRunnable;
+
+ private HttpAcceptorHandler httpHandler = null;
private final ConcurrentMap<Object, NettyConnection> connections = new
ConcurrentHashMap<Object, NettyConnection>();
@@ -352,7 +354,8 @@
handlers.put("http-encoder", new HttpResponseEncoder());
- handlers.put("http-handler", new
HttpAcceptorHandler(httpKeepAliveRunnable, httpResponseTime));
+ httpHandler = new HttpAcceptorHandler(httpKeepAliveRunnable,
httpResponseTime);
+ handlers.put("http-handler", httpHandler);
}
if (protocol == ProtocolType.CORE)
@@ -555,6 +558,11 @@
e.printStackTrace();
}
}
+
+ if (httpHandler != null)
+ {
+ httpHandler.shutdown();
+ }
paused = false;
}
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2011-08-04
20:33:29 UTC (rev 11124)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2011-08-04
23:34:24 UTC (rev 11125)
@@ -19,9 +19,14 @@
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.remoting.impl.netty.TransportConstants;
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java 2011-08-04
20:33:29 UTC (rev 11124)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java 2011-08-04
23:34:24 UTC (rev 11125)
@@ -33,6 +33,8 @@
import junit.framework.Assert;
+import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
import org.hornetq.api.core.TransportConfiguration;
@@ -209,6 +211,11 @@
context0 = null;
context1 = null;
+
+ // Shutting down Arjuna threads
+ TxControl.disable(true);
+
+ TransactionReaper.terminate(false);
super.tearDown();
}
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
20:33:29 UTC (rev 11124)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-08-04
23:34:24 UTC (rev 11125)
@@ -927,7 +927,6 @@
this.getName() +
" on this following dump"));
fail("test left broadcastgroupimpl running, this could effect other
tests");
- // System.exit(0);
}
}
}
Show replies by date