Author: fhanik
Date: Tue Mar  7 13:54:33 2006
New Revision: 384024

URL: http://svn.apache.org/viewcvs?rev=384024&view=rev
Log:
avoid memory leak in the rpc channel

Modified:
    
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/RpcChannel.java
    
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/RpcChannel.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/RpcChannel.java?rev=384024&r1=384023&r2=384024&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/RpcChannel.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/RpcChannel.java
 Tue Mar  7 13:54:33 2006
@@ -79,11 +79,15 @@
         if ( destination==null || destination.length == 0 ) return new 
Response[0];
         RpcCollectorKey key = new 
RpcCollectorKey(UUIDGenerator.randomUUID(false));
         RpcCollector collector = new 
RpcCollector(key,options,destination.length,timeout);
-        synchronized (collector) {
-            responseMap.put(key,collector);
-            RpcMessage rmsg = new RpcMessage(rpcId,key.id,message);
-            channel.send(destination,rmsg);
-            collector.wait(timeout);
+        try {
+            synchronized (collector) {
+                responseMap.put(key, collector);
+                RpcMessage rmsg = new RpcMessage(rpcId, key.id, message);
+                channel.send(destination, rmsg);
+                collector.wait(timeout);
+            }
+        }finally {
+            responseMap.remove(key);
         }
         return collector.getResponses();
     }
@@ -98,8 +102,10 @@
                 callback.leftOver(rmsg.message, sender);
             } else {
                 synchronized (collector) {
-                    collector.addResponse(rmsg.message, sender);
-                    if (collector.isComplete()) collector.notifyAll();
+                    if ( responseMap.containsKey(key) ) {
+                        collector.addResponse(rmsg.message, sender);
+                        if (collector.isComplete()) collector.notifyAll();
+                    }
                 }//synchronized
             }//end if
         } else{

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java?rev=384024&r1=384023&r2=384024&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
 Tue Mar  7 13:54:33 2006
@@ -31,6 +31,7 @@
     RpcChannel rpc;
     int options;
     long timeout;
+    String name;
     
     public EchoRpcTest(Channel channel, String name, int count, String 
message, long pause, int options, long timeout) {
         this.channel = channel;
@@ -40,6 +41,7 @@
         this.options = options;
         this.rpc = new RpcChannel(name.getBytes(),channel,this);
         this.timeout = timeout;
+        this.name = name;
     }
 
     /**
@@ -65,7 +67,7 @@
      */
     public Serializable replyRequest(Serializable msg, Member sender) {
         System.out.println("Received a reply request message from 
["+sender.getName()+"] with data ["+msg+"]");
-        return "Reply:"+msg;
+        return "Reply("+name+"):"+msg;
     }
     
     public void run() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to