[jboss-cvs] JBossAS SVN: r89146 - in trunk/jmx-remoting/src/main/org/jboss/mx/remoting: rmi and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 19 22:52:50 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-05-19 22:52:50 -0400 (Tue, 19 May 2009)
New Revision: 89146

Modified:
   trunk/jmx-remoting/src/main/org/jboss/mx/remoting/MBeanNotificationCache.java
   trunk/jmx-remoting/src/main/org/jboss/mx/remoting/rmi/ClientNotificationProxy.java
Log:
JBAS-6951: wrong interrupt handling

Modified: trunk/jmx-remoting/src/main/org/jboss/mx/remoting/MBeanNotificationCache.java
===================================================================
--- trunk/jmx-remoting/src/main/org/jboss/mx/remoting/MBeanNotificationCache.java	2009-05-20 02:51:09 UTC (rev 89145)
+++ trunk/jmx-remoting/src/main/org/jboss/mx/remoting/MBeanNotificationCache.java	2009-05-20 02:52:50 UTC (rev 89146)
@@ -287,6 +287,7 @@
                }
                catch(InterruptedException ex)
                {
+                  Thread.currentThread().interrupt();
                   break;
                }
             }
@@ -405,6 +406,7 @@
                }
                catch(InterruptedException ex)
                {
+                  Thread.currentThread().interrupt();
                   break;
                }
             }
@@ -450,7 +452,7 @@
                }
                catch(InterruptedException ie)
                {
-
+                  Thread.currentThread().interrupt();
                }
             }
          }

Modified: trunk/jmx-remoting/src/main/org/jboss/mx/remoting/rmi/ClientNotificationProxy.java
===================================================================
--- trunk/jmx-remoting/src/main/org/jboss/mx/remoting/rmi/ClientNotificationProxy.java	2009-05-20 02:51:09 UTC (rev 89145)
+++ trunk/jmx-remoting/src/main/org/jboss/mx/remoting/rmi/ClientNotificationProxy.java	2009-05-20 02:52:50 UTC (rev 89146)
@@ -116,23 +116,51 @@
       NotificationResult result = null;
       boolean waitForTimeout = true;
       boolean timeoutReached = false;
-
       int startIndex = 0;
-
-      while(waitForTimeout)
+      boolean intr = false;
+      try
       {
-         synchronized(clientListenerNotifications)
+         while(waitForTimeout)
          {
-            waitForTimeout = false;
-
-            // since the startSequence should be in sync with the first (0) index of the clientListenerNotifications,
-            // will use this to determine how far up the index to start.
-            if(clientSequenceNumber > startSequence)
+            synchronized(clientListenerNotifications)
             {
-               startIndex = (int) (clientSequenceNumber - startSequence);
+               waitForTimeout = false;
 
-               if(startIndex > clientListenerNotifications.size())
+               // since the startSequence should be in sync with the first (0) index of the clientListenerNotifications,
+               // will use this to determine how far up the index to start.
+               if(clientSequenceNumber > startSequence)
                {
+                  startIndex = (int) (clientSequenceNumber - startSequence);
+
+                  if(startIndex > clientListenerNotifications.size())
+                  {
+                     if(timeout > 0 && !timeoutReached)
+                     {
+                        //need to wait
+                        try
+                        {
+                           clientListenerNotifications.wait(timeout);
+                           waitForTimeout = true;
+                           timeoutReached = true;
+                        }
+                        catch(InterruptedException e)
+                        {
+                           intr = true;
+                           log.trace("Caught InterruptedException waiting for clientListenerNotifications.");
+                        }
+                     }
+                     else
+                     {
+                        startIndex = clientListenerNotifications.size();
+                     }
+                  }
+               }
+
+               int endIndex = maxNotifications > (clientListenerNotifications.size() - startIndex) ? clientListenerNotifications.size() : maxNotifications;
+
+               // handle timeout
+               if(endIndex == startIndex)
+               {
                   if(timeout > 0 && !timeoutReached)
                   {
                      //need to wait
@@ -144,45 +172,25 @@
                      }
                      catch(InterruptedException e)
                      {
+                        intr = true;
                         log.debug("Caught InterruptedException waiting for clientListenerNotifications.");
                      }
                   }
-                  else
-                  {
-                     startIndex = clientListenerNotifications.size();
-                  }
                }
-            }
 
-            int endIndex = maxNotifications > (clientListenerNotifications.size() - startIndex) ? clientListenerNotifications.size() : maxNotifications;
+               List fetchedNotifications = clientListenerNotifications.subList(startIndex, endIndex);
+               TargetedNotification[] targetedNotifications = (TargetedNotification[]) fetchedNotifications.toArray(new TargetedNotification[fetchedNotifications.size()]);
 
-            // handle timeout
-            if(endIndex == startIndex)
-            {
-               if(timeout > 0 && !timeoutReached)
-               {
-                  //need to wait
-                  try
-                  {
-                     clientListenerNotifications.wait(timeout);
-                     waitForTimeout = true;
-                     timeoutReached = true;
-                  }
-                  catch(InterruptedException e)
-                  {
-                     log.debug("Caught InterruptedException waiting for clientListenerNotifications.");
-                  }
-               }
+               result = new NotificationResult(clientSequenceNumber, currentSequence, targetedNotifications);
             }
+         }
 
-            List fetchedNotifications = clientListenerNotifications.subList(startIndex, endIndex);
-            TargetedNotification[] targetedNotifications = (TargetedNotification[]) fetchedNotifications.toArray(new TargetedNotification[fetchedNotifications.size()]);
-
-            result = new NotificationResult(clientSequenceNumber, currentSequence, targetedNotifications);
-         }
+         return result;
       }
-
-      return result;
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
    }
 
    public ClientListenerHolder[] getListeners()




More information about the jboss-cvs-commits mailing list