[jboss-remoting-commits] JBoss Remoting SVN: r5459 - remoting2/branches/2.x/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Sat Sep 12 12:27:01 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-09-12 12:27:00 -0400 (Sat, 12 Sep 2009)
New Revision: 5459

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1154: sendClientPing() and addClient() throw exceptions instead of swallowing them.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java	2009-09-12 16:26:15 UTC (rev 5458)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java	2009-09-12 16:27:00 UTC (rev 5459)
@@ -205,8 +205,16 @@
       ClientHolder newClient = new ClientHolder(sessionID, configuration, leasePeriod);
       clientSessionIds.put(sessionID, newClient);
 
-      sendClientPing();
-
+      try
+      {
+         sendClientPing();
+      }
+      catch (Throwable t)
+      {
+         log.debug(this + " failed to ping to server", t);
+         log.warn(this + " failed to ping to server: " + t.getMessage());
+         throw new RuntimeException(t);
+      }
       // if new client lease period is less than the current ping period, need to refresh to new one
       if (leasePeriod < pingPeriod)
       {
@@ -372,53 +380,44 @@
    
    // Private --------------------------------------------------------------------------------------
 
-   private void sendClientPing()
+   private void sendClientPing() throws Throwable
    {
-      try
+      if(trace)
       {
-         if(trace)
+         StringBuffer sb = new StringBuffer();
+         if(clientSessionIds != null)
          {
-            StringBuffer sb = new StringBuffer();
-            if(clientSessionIds != null)
+            for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
             {
-               for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
-               {
-                  ClientHolder h = (ClientHolder)i.next();
-                  sb.append("    ").append(h.getSessionId()).append('\n');
-               }
+               ClientHolder h = (ClientHolder)i.next();
+               sb.append("    ").append(h.getSessionId()).append('\n');
             }
-
-            log.trace(this + " sending ping to server. Currently managing lease " +
-                      "for following clients:\n" + sb.toString());
          }
 
-         Map clientsClone = new ConcurrentHashMap(clientSessionIds);
-         Map requestClients = new ConcurrentHashMap();
-         requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
-         requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
-         requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
+         log.trace(this + " sending ping to server. Currently managing lease " +
+               "for following clients:\n" + sb.toString());
+      }
 
-         if (leasePingerTimeout >= 0)
-         {
-            requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout));
-         }
-         
-         InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
-         
-         pingSucceeded = false;
-         pingInvoked = true;
-         invoker.invoke(ir);
+      Map clientsClone = new ConcurrentHashMap(clientSessionIds);
+      Map requestClients = new ConcurrentHashMap();
+      requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
+      requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
+      requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
 
-         pingSucceeded = true;
-         pingInvoked = false;
-         if(trace) { log.trace(this + " successfully pinged the server"); }
-      }
-      catch (Throwable t)
+      if (leasePingerTimeout >= 0)
       {
-         pingInvoked = false;
-         log.debug(this + " failed to ping to server", t);
-         log.warn(this + " failed to ping to server: " + t.getMessage());
+         requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout));
       }
+      
+      InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
+      
+      pingSucceeded = false;
+      pingInvoked = true;
+      invoker.invoke(ir);
+
+      pingSucceeded = true;
+      pingInvoked = false;
+      if(trace) { log.trace(this + " successfully pinged the server"); }
    }
 
    // Inner classes --------------------------------------------------------------------------------
@@ -442,7 +441,15 @@
 
          if (currentPinger != null)
          {
-             currentPinger.sendClientPing();
+            try
+            {
+               currentPinger.sendClientPing();
+            }
+            catch (Throwable t)
+            {
+               log.debug(this + " failed to ping to server", t);
+               log.warn(this + " failed to ping to server: " + t.getMessage());
+            }
          }
       }
 



More information about the jboss-remoting-commits mailing list