You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by sf...@apache.org on 2009/06/15 08:56:46 UTC

svn commit: r784671 - /felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java

Author: sfrenot
Date: Mon Jun 15 06:56:45 2009
New Revision: 784671

URL: http://svn.apache.org/viewvc?rev=784671&view=rev
Log:
FELIX-1188
----------
Applied a correcting patch when stopping rmiconnections. 

1. Call stop()
2. If there were pending connections, stop() closes all of them but throws an IOException
3. Catch the exception and call stop() again
4. This time, it should not throw anything and stop successfully



Modified:
    felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java

Modified: felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java?rev=784671&r1=784670&r2=784671&view=diff
==============================================================================
--- felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java (original)
+++ felix/trunk/mosgi/jmx.rmiconnector/src/main/java/org/apache/felix/mosgi/jmx/rmiconnector/RmiConnectorActivator.java Mon Jun 15 06:56:45 2009
@@ -37,6 +37,7 @@
 
 import org.apache.felix.mosgi.jmx.registry.mx4j.tools.naming.NamingServiceIfc;  
 
+import java.io.IOException;
 import java.net.InetAddress;
 
 public class RmiConnectorActivator implements BundleActivator, ServiceListener{
@@ -96,7 +97,7 @@
           try{
             this.startRmiConnector();
           }catch (Exception e){
-            e.printStackTrace();
+            this.log(LogService.LOG_ERROR, "cannot start rmi connector", e);
           }
         }
         break;
@@ -104,7 +105,7 @@
         try{
           this.stopRmiConnector();
         }catch (Exception e){
-          e.printStackTrace();
+          this.log(LogService.LOG_ERROR, "cannot stop rmi connector", e);
         }
         break;
     }
@@ -177,7 +178,16 @@
   private void stopRmiConnector() throws Exception {
     RmiConnectorActivator.log(LogService.LOG_INFO, "Stopping JMX Rmi connector "+version,null);
     if (this.connectorServer!=null){
-      this.connectorServer.stop();
+      try {
+        // The first call to stop() will close any open connections, but will
+        // throw an exception if there were open connections.
+        this.connectorServer.stop();
+      }catch(IOException e){
+        // Exception probably thrown because there were open connections. When
+        // this exception is thrown, the server has already attempted to close
+        // all client connections, try stopping again.
+        this.connectorServer.stop();
+      }
       this.connectorServer=null;
     }