[jboss-cvs] JBoss Messaging SVN: r7905 - in branches/Branch_1_4: tests/src/org/jboss/test/messaging/jms and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 24 07:05:00 EST 2009
Author: gaohoward
Date: 2009-11-24 07:04:59 -0500 (Tue, 24 Nov 2009)
New Revision: 7905
Modified:
branches/Branch_1_4/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java
Log:
JBMESSAGING-1751
Modified: branches/Branch_1_4/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2009-11-23 20:02:37 UTC (rev 7904)
+++ branches/Branch_1_4/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2009-11-24 12:04:59 UTC (rev 7905)
@@ -61,7 +61,7 @@
// Constants ------------------------------------------------------------------------------------
private static final long serialVersionUID = 2512460695662741413L;
-
+
// Attributes -----------------------------------------------------------------------------------
//This data is needed in order to create a connection
@@ -240,12 +240,24 @@
//We execute this on its own client
- Client theClient = createClient();
+ Client theClient = null;
+ try
+ {
+ theClient = createClient();
- ConnectionFactoryGetClientAOPStackRequest req =
- new ConnectionFactoryGetClientAOPStackRequest(id, v);
+ ConnectionFactoryGetClientAOPStackRequest req =
+ new ConnectionFactoryGetClientAOPStackRequest(id, v);
- return (byte[])doInvoke(theClient, req);
+ return (byte[])doInvoke(theClient, req);
+ }
+ finally
+ {
+ if (theClient != null)
+ {
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1751
+ theClient.disconnect();
+ }
+ }
}
public TopologyResult getTopology() throws JMSException
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java 2009-11-23 20:02:37 UTC (rev 7904)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java 2009-11-24 12:04:59 UTC (rev 7905)
@@ -21,6 +21,9 @@
*/
package org.jboss.test.messaging.jms;
+import java.lang.reflect.Field;
+import java.util.Map;
+
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Message;
@@ -33,12 +36,19 @@
import javax.jms.TopicSession;
import javax.jms.TopicSubscriber;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.client.remoting.JMSRemotingConnection;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
+
/**
* All tests related to closing a Connection.
*
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -67,7 +77,41 @@
Connection conn = cf.createConnection();
conn.close();
}
+
+ public void testCloseClientLeak() throws Exception
+ {
+ JBossConnection conn = (JBossConnection)cf.createConnection();
+ try
+ {
+ ClientConnectionDelegate delegate = (ClientConnectionDelegate)conn.getDelegate();
+ JMSRemotingConnection rmconn = delegate.getRemotingConnection();
+ Client client = rmconn.getRemotingClient();
+ MicroSocketClientInvoker invoker = (MicroSocketClientInvoker)client.getInvoker();
+
+ Field[] fields = MicroSocketClientInvoker.class.getDeclaredFields();
+ Field poolsField = null;
+
+ for (Field f : fields)
+ {
+ if ("connectionPools".equals(f.getName()))
+ {
+ poolsField = f;
+ poolsField.setAccessible(true);
+ break;
+ }
+ }
+
+ Map pools = (Map)poolsField.get(invoker);
+
+ assertEquals(2, pools.size());
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+
public void testCloseTwice() throws Exception
{
Connection conn = cf.createConnection();
More information about the jboss-cvs-commits
mailing list