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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Thu Jun 26 22:58:47 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-06-26 22:58:47 -0400 (Thu, 26 Jun 2008)
New Revision: 4325

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1005: (1) TimerTasks aren't created if pingFrequency == 0.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java	2008-06-24 02:12:30 UTC (rev 4324)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java	2008-06-27 02:58:47 UTC (rev 4325)
@@ -283,24 +283,28 @@
                throw new ConnectionFailedException("Unable to get control socket output stream");
             }
             log.debug("got control socket( " + listenerId + "): " + controlSocket);
-            pingTimerTask = new PingTimerTask(this);
 
-            synchronized (timerLock)
+            if (pingFrequency > 0)
             {
-               if (timer == null)
+               pingTimerTask = new PingTimerTask(this);
+
+               synchronized (timerLock)
                {
-                  timer = new Timer(true);
+                  if (timer == null)
+                  {
+                     timer = new Timer(true);
+                  }
+                  try
+                  {
+                     timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+                  }
+                  catch (IllegalStateException e)
+                  {
+                     log.debug("Unable to schedule TimerTask on existing Timer", e);
+                     timer = new Timer(true);
+                     timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+                  }
                }
-               try
-               {
-                  timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
-               }
-               catch (IllegalStateException e)
-               {
-                  log.debug("Unable to schedule TimerTask on existing Timer", e);
-                  timer = new Timer(true);
-                  timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
-               }
             }
          }
 
@@ -523,24 +527,27 @@
       if (pingTimerTask != null)
          pingTimerTask.cancel();
 
-      pingTimerTask = new PingTimerTask(this);
+      if (pingFrequency > 0)
+      {
+         pingTimerTask = new PingTimerTask(this);
 
-      synchronized (timerLock)
-      {
-         if (timer == null)
+         synchronized (timerLock)
          {
-            timer = new Timer(true);
+            if (timer == null)
+            {
+               timer = new Timer(true);
+            }
+            try
+            {
+               timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+            }
+            catch (IllegalStateException e)
+            {
+               log.debug("Unable to schedule TimerTask on existing Timer", e);
+               timer = new Timer(true);
+               timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+            }
          }
-         try
-         {
-            timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
-         }
-         catch (IllegalStateException e)
-         {
-            log.debug("Unable to schedule TimerTask on existing Timer", e);
-            timer = new Timer(true);
-            timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
-         }
       }
    }
 
@@ -619,6 +626,7 @@
             controlOutputStream = null;
          }
          cancel();
+         timer.purge();
       }
 
       public void run()

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java	2008-06-24 02:12:30 UTC (rev 4324)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java	2008-06-27 02:58:47 UTC (rev 4325)
@@ -157,23 +157,26 @@
          threadpool = new LinkedList();
          checkSocketFactoryWrapper();
 
-         controlMonitorTimerTask = new ControlMonitorTimerTask(this);
-         synchronized (timerLock)
+         if (pingFrequency > 0)
          {
-            if (timer == null)
+            controlMonitorTimerTask = new ControlMonitorTimerTask(this);
+            synchronized (timerLock)
             {
-               timer = new Timer(true);
+               if (timer == null)
+               {
+                  timer = new Timer(true);
+               }
+               try
+               {
+                  timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+               }
+               catch (IllegalStateException e)
+               {
+                  log.debug("Unable to schedule TimerTask on existing Timer", e);
+                  timer = new Timer(true);
+                  timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+               }
             }
-            try
-            {
-               timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
-            }
-            catch (IllegalStateException e)
-            {
-               log.debug("Unable to schedule TimerTask on existing Timer", e);
-               timer = new Timer(true);
-               timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
-            }
          }
          
          running = true;
@@ -1197,6 +1200,7 @@
          listenerIdToInvokerLocatorMap = null;
          controlConnectionThreadMap = null;
          cancel();
+         timer.purge();
       }
 
       public void run()




More information about the jboss-remoting-commits mailing list