JBoss Remoting SVN: r4985 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 06:32:31 -0400 (Mon, 13 Apr 2009)
New Revision: 4985
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-1113: Added shutdown() method.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-04-13 10:31:34 UTC (rev 4984)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-04-13 10:32:31 UTC (rev 4985)
@@ -85,6 +85,7 @@
private SerializableStore callbackStore = null;
private CallbackErrorHandler callbackErrorHandler = null;
+ private ServerInvoker serverInvoker;
/**
* The map key to use when looking up any callback store that
@@ -170,6 +171,7 @@
private void init(InvocationRequest invocation, ServerInvoker owner) throws Exception
{
+ serverInvoker = owner;
clientSessionId = invocation.getSessionId();
sessionId = invocation.getSessionId();
@@ -1025,12 +1027,18 @@
}
}
+ public void shutdown()
+ {
+ serverInvoker.shutdownCallbackHandler(this, invocation);
+ destroy();
+ log.debug(this + " shut down");
+ }
+
public void handleConnectionException(Throwable throwable, Client client)
{
if (clientSessionId.equals(client.getSessionId()))
{
- destroy();
- log.debug(this + " shut down");
+ shutdown();
}
}
15 years, 7 months
JBoss Remoting SVN: r4984 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 06:31:34 -0400 (Mon, 13 Apr 2009)
New Revision: 4984
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1113: (1) Made removeCallbackHandler() public; (2) added shutdownCallbackHandler().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2009-04-13 10:29:47 UTC (rev 4983)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2009-04-13 10:31:34 UTC (rev 4984)
@@ -867,28 +867,7 @@
//then it will just use that without having to do a lookup or HashMap iteration over
//values
- ServerInvocationHandler handler = null;
-
- if (singleHandler != null)
- {
- handler = singleHandler;
- }
- else
- {
- if (subsystem != null)
- {
- handler = (ServerInvocationHandler)handlers.get(subsystem.toUpperCase());
- }
- else
- {
- // subsystem not specified, so will hope for a default one being set
- if (!handlers.isEmpty())
- {
- if (trace) { log.trace(this + " handling invocation with no subsystem explicitely specified, using the default handler"); }
- handler = (ServerInvocationHandler)handlers.values().iterator().next();
- }
- }
- }
+ ServerInvocationHandler handler = findInvocationHandler(subsystem);
if (param instanceof InternalInvocation)
{
@@ -1664,6 +1643,10 @@
if (registerCallbackListeners)
{
connectionNotifier.addListenerFirst(callbackHandler);
+ if(leasePeriod > 0)
+ {
+ leaseManagement = true;
+ }
}
handler.addListener(callbackHandler);
}
@@ -1672,6 +1655,14 @@
ServerInvokerCallbackHandler callbackHandler = removeCallbackHandler(invocation);
if(callbackHandler != null)
{
+ if (registerCallbackListeners)
+ {
+// connectionNotifier.removeListener(callbackHandler);
+ removeConnectionListener(callbackHandler);
+ }
+
+ callbackHandler.destroy();
+
if(handler == null)
{
throw new InvalidConfigurationException(
@@ -1679,15 +1670,10 @@
"registered. Please add via xml configuration or via the Connector's " +
"addInvocationHandler() method.");
}
- if (registerCallbackListeners)
- {
- connectionNotifier.removeListener(callbackHandler);
- }
+
handler.removeListener(callbackHandler);
if(trace) { log.trace("ServerInvoker (" + this + ") removing server callback handler " + callbackHandler + "."); }
-
- callbackHandler.destroy();
}
else
{
@@ -1815,7 +1801,34 @@
}
return result;
}
+
+ protected ServerInvocationHandler findInvocationHandler(String subsystem)
+ {
+ ServerInvocationHandler handler = null;
+ if (singleHandler != null)
+ {
+ handler = singleHandler;
+ }
+ else
+ {
+ if (subsystem != null)
+ {
+ handler = (ServerInvocationHandler)handlers.get(subsystem.toUpperCase());
+ }
+ else
+ {
+ // subsystem not specified, so will hope for a default one being set
+ if (!handlers.isEmpty())
+ {
+ if (trace) { log.trace(this + " handling invocation with no subsystem explicitely specified, using the default handler"); }
+ handler = (ServerInvocationHandler)handlers.values().iterator().next();
+ }
+ }
+ }
+ return handler;
+ }
+
/**
* Called prior to an invocation.
* TODO is sending in the arg appropriate?
@@ -2049,7 +2062,7 @@
return callbackHandler;
}
- private ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest invocation)
+ public ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest invocation)
{
String id = ServerInvokerCallbackHandler.getId(invocation);
ServerInvokerCallbackHandler callbackHandler = null;
@@ -2060,6 +2073,25 @@
}
return callbackHandler;
}
+
+ public void shutdownCallbackHandler(ServerInvokerCallbackHandler callbackHandler, InvocationRequest invocation)
+ {
+ removeCallbackHandler(invocation);
+ if (registerCallbackListeners)
+ {
+ removeConnectionListener(callbackHandler);
+ }
+ ServerInvocationHandler handler = findInvocationHandler(invocation.getSessionId());
+ if (handler != null)
+ {
+ handler.removeListener(callbackHandler);
+ if(trace) { log.trace(this + " removing server callback handler " + callbackHandler + "."); }
+ }
+ else
+ {
+ log.debug(this + " cannot remove " + callbackHandler + ": associated ServerInvocationHandler not longer exists");
+ }
+ }
// Inner classes --------------------------------------------------------------------------------
15 years, 7 months
JBoss Remoting SVN: r4983 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 06:29:47 -0400 (Mon, 13 Apr 2009)
New Revision: 4983
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java
Log:
JBREM-1113: Use copies of lists to avoid ConcurrentModificationException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java 2009-04-13 06:49:46 UTC (rev 4982)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java 2009-04-13 10:29:47 UTC (rev 4983)
@@ -47,14 +47,17 @@
Client client = new Client(new InvokerLocator(locatorurl), requestPayload);
client.setSessionId(clientSessionId);
+ ArrayList localListeners = null;
synchronized (listeners)
{
- Iterator it = listeners.iterator();
- while (it.hasNext())
- {
- ((ConnectionListener) it.next()).handleConnectionException(null, client);
- }
+ localListeners = new ArrayList(listeners);
}
+
+ Iterator it = localListeners.iterator();
+ while (it.hasNext())
+ {
+ ((ConnectionListener) it.next()).handleConnectionException(null, client);
+ }
}
catch(Exception e)
{
@@ -74,14 +77,17 @@
client.setSessionId(clientSessionId);
ClientDisconnectedException ex = new ClientDisconnectedException();
+ ArrayList localListeners = null;
synchronized (listeners)
{
- Iterator it = listeners.iterator();
- while (it.hasNext())
- {
- ((ConnectionListener) it.next()).handleConnectionException(ex, client);
- }
+ localListeners = new ArrayList(listeners);
}
+
+ Iterator it = localListeners.iterator();
+ while (it.hasNext())
+ {
+ ((ConnectionListener) it.next()).handleConnectionException(ex, client);
+ }
}
catch(Exception e)
{
15 years, 7 months
JBoss Remoting SVN: r4982 - remoting2/branches/2.x/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 02:49:46 -0400 (Mon, 13 Apr 2009)
New Revision: 4982
Modified:
remoting2/branches/2.x/docs/guide/en/chap5.xml
Log:
JBREM-1114: Added description of "unwrapSingletonArray" parameter.
Modified: remoting2/branches/2.x/docs/guide/en/chap5.xml
===================================================================
--- remoting2/branches/2.x/docs/guide/en/chap5.xml 2009-04-13 06:24:32 UTC (rev 4981)
+++ remoting2/branches/2.x/docs/guide/en/chap5.xml 2009-04-13 06:49:46 UTC (rev 4982)
@@ -2065,6 +2065,14 @@
<classname>ServerInvokerServlet</classname> will still use "jboss" as the
default domain.</para>
+ <section>
+ <title>Configuration</title>
+
+ <para><emphasis role="bold">unwrapSingletonArrays</emphasis> - If the map
+ returned by <methodname>javax.servlet.http.HttpServletRequest.getParameterMap()</methodname>
+ maps a String key to an array of length one, the value in the array will be extracted
+ and associated with the key.</para>
+ </section>
</section>
<section>
@@ -6444,6 +6452,16 @@
</section>
<section>
+ <title>org.jboss.remoting.transport.servlet.ServletServerInvoker</title>
+
+ <para><emphasis role="bold">UNWRAP_SINGLETON_ARRAYS</emphasis> (actual value
+ is 'unwrapSingletonArrays') - If the map returned by
+ <methodname>javax.servlet.http.HttpServletRequest.getParameterMap()</methodname>
+ maps a String key to an array of length one, the value in the array will be
+ extracted and associated with the key.</para>
+ </section>
+
+ <section>
<title>org.jboss.remoting.transport.socket.MicroSocketClientInvoker</title>
<para><emphasis role="bold">TCP_NODELAY_FLAG</emphasis> (actual value is
15 years, 7 months
JBoss Remoting SVN: r4981 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/web.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 02:24:32 -0400 (Mon, 13 Apr 2009)
New Revision: 4981
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/web/ServerInvokerServlet.java
Log:
JBREM-1114: Added some logging.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/web/ServerInvokerServlet.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/web/ServerInvokerServlet.java 2009-04-13 06:23:56 UTC (rev 4980)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/web/ServerInvokerServlet.java 2009-04-13 06:24:32 UTC (rev 4981)
@@ -75,7 +75,15 @@
{
throw new ServletException("Could not find init parameter for 'locatorUrl' or 'locatorName' - one of which must be supplied for ServerInvokerServlet to function.");
}
+ else
+ {
+ log.debug("Got ServletServerInvoker from InvokerName: " + config.getInitParameter("invokerName"));
+ }
}
+ else
+ {
+ log.debug("Got ServletServerInvoker from InvokerLocator: " + config.getInitParameter("locatorUrl"));
+ }
}
/**
15 years, 7 months
JBoss Remoting SVN: r4980 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-13 02:23:56 -0400 (Mon, 13 Apr 2009)
New Revision: 4980
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1114: (1) Added "unwrapSingletonArray" parameter; (2) creates new InvocationRequest if request body is null.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-04-13 03:50:21 UTC (rev 4979)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-04-13 06:23:56 UTC (rev 4980)
@@ -48,10 +48,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -66,22 +62,47 @@
*/
public class ServletServerInvoker extends WebServerInvoker implements ServletServerInvokerMBean
{
+ public static final String UNWRAP_SINGLETON_ARRAYS = "unwrapSingletonArrays";
+
private static final Logger log = Logger.getLogger(ServletServerInvoker.class);
+
+ private boolean unwrapSingletonArrays;
public ServletServerInvoker(InvokerLocator locator)
{
super(locator);
+ init();
}
public ServletServerInvoker(InvokerLocator locator, Map configuration)
{
super(locator, configuration);
+ init();
}
protected String getDefaultDataType()
{
return HTTPMarshaller.DATATYPE;
}
+
+ protected void init()
+ {
+ Object val = configuration.get(UNWRAP_SINGLETON_ARRAYS);
+ if (val != null)
+ {
+ try
+ {
+ unwrapSingletonArrays = Boolean.valueOf((String)val).booleanValue();
+ log.debug(this + " setting unwrapSingletonArrays to " + unwrapSingletonArrays);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
+ UNWRAP_SINGLETON_ARRAYS + " value of " +
+ val + " to a boolean value.");
+ }
+ }
+ }
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
@@ -97,8 +118,37 @@
}
Map urlParams = request.getParameterMap();
- metadata.putAll(urlParams);
+ if (unwrapSingletonArrays)
+ {
+ Iterator it = urlParams.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ Object value = urlParams.get(key);
+ String[] valueArray = (String[]) value;
+ if (valueArray.length == 1)
+ {
+ value = valueArray[0];
+ }
+ metadata.put(key, value);
+ }
+ }
+ else
+ {
+ metadata.putAll(urlParams);
+ }
+ if(log.isTraceEnabled())
+ {
+ log.trace("metadata:");
+ Iterator it = metadata.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ log.trace(" " + key + ": " + metadata.get(key));
+ }
+ }
+
// UnMarshaller may not be an HTTPUnMarshaller, in which case it
// can ignore this parameter.
Object o = configuration.get(HTTPUnMarshaller.PRESERVE_LINES);
@@ -222,7 +272,25 @@
}
Map urlParams = request.getParameterMap();
- metadata.putAll(urlParams);
+ if (unwrapSingletonArrays)
+ {
+ Iterator it = urlParams.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ Object value = urlParams.get(key);
+ String[] valueArray = (String[]) value;
+ if (valueArray.length == 1)
+ {
+ value = valueArray[0];
+ }
+ metadata.put(key, value);
+ }
+ }
+ else
+ {
+ metadata.putAll(urlParams);
+ }
metadata.put(HTTPMetadataConstants.METHODTYPE, request.getMethod());
@@ -250,43 +318,50 @@
try
{
+ InvocationRequest invocationRequest = null;
Object responseObject = null;
-
- ServletInputStream inputStream = request.getInputStream();
- UnMarshaller unmarshaller = getUnMarshaller();
- Object obj = null;
- if (unmarshaller instanceof VersionedUnMarshaller)
- obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, getVersion());
- else
- obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
- inputStream.close();
-
boolean isError = false;
- InvocationRequest invocationRequest = null;
- if(obj instanceof InvocationRequest)
+ String method = request.getMethod();
+ if (method.equals("GET") || method.equals("HEAD") || (method.equals("OPTIONS") && request.getContentLength() <= 0))
{
- invocationRequest = (InvocationRequest) obj;
-
- Map requestMap = invocationRequest.getRequestPayload();
- if (requestMap == null)
- {
- invocationRequest.setRequestPayload(metadata);
- }
- else
- {
- requestMap.putAll(metadata);
- }
+ invocationRequest = createNewInvocationRequest(metadata, null);
}
else
{
- if(WebUtil.isBinary(requestContentType))
+ ServletInputStream inputStream = request.getInputStream();
+ UnMarshaller unmarshaller = getUnMarshaller();
+ Object obj = null;
+ if (unmarshaller instanceof VersionedUnMarshaller)
+ obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, getVersion());
+ else
+ obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
+ inputStream.close();
+
+ if(obj instanceof InvocationRequest)
{
- invocationRequest = getInvocationRequest(metadata, obj);
+ invocationRequest = (InvocationRequest) obj;
+
+ Map requestMap = invocationRequest.getRequestPayload();
+ if (requestMap == null)
+ {
+ invocationRequest.setRequestPayload(metadata);
+ }
+ else
+ {
+ requestMap.putAll(metadata);
+ }
}
else
{
- invocationRequest = createNewInvocationRequest(metadata, obj);
+ if(WebUtil.isBinary(requestContentType))
+ {
+ invocationRequest = getInvocationRequest(metadata, obj);
+ }
+ else
+ {
+ invocationRequest = createNewInvocationRequest(metadata, obj);
+ }
}
}
15 years, 7 months
JBoss Remoting SVN: r4979 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/datatype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-12 23:50:21 -0400 (Sun, 12 Apr 2009)
New Revision: 4979
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java
Log:
JBREM-1109: Reduced number of threads to 1000 to avoid "java.lang.OutOfMemoryError: unable to create new native thread".
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java 2009-04-13 03:47:59 UTC (rev 4978)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java 2009-04-13 03:50:21 UTC (rev 4979)
@@ -111,7 +111,7 @@
// Test datatype race.
MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker();
- int THREADS = 2000;
+ int THREADS = 1000;
TestThread[] threads = new TestThread[THREADS];
Rendezvous startBarrier = new Rendezvous(THREADS);
Rendezvous stopBarrier = new Rendezvous(THREADS + 1);
15 years, 7 months
JBoss Remoting SVN: r4978 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/datatype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-12 23:47:59 -0400 (Sun, 12 Apr 2009)
New Revision: 4978
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java
Log:
JBREM-1109: Reduced number of threads to 1000 to avoid "java.lang.OutOfMemoryError: unable to create new native thread".
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java 2009-04-13 01:49:38 UTC (rev 4977)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java 2009-04-13 03:47:59 UTC (rev 4978)
@@ -111,7 +111,7 @@
// Test datatype race.
MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker();
- int THREADS = 2000;
+ int THREADS = 1000;
TestThread[] threads = new TestThread[THREADS];
Rendezvous startBarrier = new Rendezvous(THREADS);
Rendezvous stopBarrier = new Rendezvous(THREADS + 1);
15 years, 7 months
JBoss Remoting SVN: r4977 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-12 21:49:38 -0400 (Sun, 12 Apr 2009)
New Revision: 4977
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java
Log:
JBREM-1083: Added testStaticTimer().
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java 2009-04-13 01:39:51 UTC (rev 4976)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java 2009-04-13 01:49:38 UTC (rev 4977)
@@ -21,9 +21,11 @@
*/
package org.jboss.test.remoting.invoker;
+import java.lang.reflect.Field;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
+import java.util.Timer;
import javax.management.MBeanServer;
@@ -33,7 +35,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
@@ -76,7 +77,7 @@
if (firstTime)
{
firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
PatternLayout layout = new PatternLayout(pattern);
@@ -262,6 +263,49 @@
}
+ public void testStaticTimer() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+
+ // Get static Timer.
+ Field field = Client.class.getDeclaredField("invokerDestructionTimer");
+ field.setAccessible(true);
+ Timer invokerDestructionTimer = (Timer) field.get(null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "5000");
+ addExtraClientConfig(clientConfig);
+ Client[] clients = new Client[50];
+
+ for (int i = 0; i < 50; i++)
+ {
+ clients[i] = new Client(clientLocator, clientConfig);
+ clients[i].connect();
+ assertEquals("abc", clients[i].invoke("abc"));
+ clients[i].disconnect();
+ }
+
+ // Verify all Clients are using the same Timer.
+ for (int i = 0; i < 50; i++)
+ {
+ assertEquals("Should be the same Timer", invokerDestructionTimer, field.get(clients[i]));
+ }
+
+ Thread.sleep(10000);
+ assertEquals(0, InvokerRegistry.getClientInvokers().length);
+
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
protected String getTransport()
{
return "socket";
15 years, 7 months
JBoss Remoting SVN: r4976 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-12 21:39:51 -0400 (Sun, 12 Apr 2009)
New Revision: 4976
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1083: (1) Made invokerDestructionTimer and invokerDestructionTimerLock static; (2) made invoker reference in InvokerDesctructionTimerTask a WeakReference.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-04-12 07:24:18 UTC (rev 4975)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-04-13 01:39:51 UTC (rev 4976)
@@ -51,6 +51,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.StreamCorruptedException;
+import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.net.SocketTimeoutException;
import java.rmi.MarshalException;
@@ -172,6 +173,9 @@
private static final Logger log = Logger.getLogger(Client.class);
private static final long serialVersionUID = 5679279425009837934L;
+
+ private static Timer invokerDestructionTimer;
+ private static Object invokerDestructionTimerLock = new Object();
// Static ---------------------------------------------------------------------------------------
@@ -205,8 +209,6 @@
private boolean connected = false;
private int invokerDestructionDelay = 0;
- private Timer invokerDestructionTimer;
- private Object invokerDestructionTimerLock = new Object();
// Constructors ---------------------------------------------------------------------------------
@@ -1843,17 +1845,20 @@
// Inner classes --------------------------------------------------------------------------------
class InvokerDestructionTimerTask extends TimerTask
{
- private ClientInvoker invoker;
+ private WeakReference ref;
public InvokerDestructionTimerTask(ClientInvoker invoker)
{
- this.invoker = invoker;
+ ref = new WeakReference(invoker);
}
public void run()
{
- log.trace("calling InvokerRegistry.destroyClientInvoker() for " + invoker);
+ ClientInvoker invoker = (ClientInvoker) ref.get();
+ log.trace(this + " calling InvokerRegistry.destroyClientInvoker() for " + invoker);
InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
+ ref.clear();
+ ref = null;
}
}
}
15 years, 7 months