[jboss-cvs] JBossAS SVN: r89154 - in trunk/connector/src/main/org/jboss/resource: adapter/jms and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 19 23:14:06 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-05-19 23:14:06 -0400 (Tue, 19 May 2009)
New Revision: 89154

Modified:
   trunk/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java
   trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java
   trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
   trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java
   trunk/connector/src/main/org/jboss/resource/adapter/mail/MailResourceAdapter.java
   trunk/connector/src/main/org/jboss/resource/adapter/mail/inflow/NewMsgsWorker.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/ConnectionValidator.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/IdleRemover.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/PoolFiller.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/TransactionSynchronizer.java
Log:
JBAS-6958 - wrong interrupt handling

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -268,6 +268,7 @@
       }
       catch (InterruptedException e)
       {
+         Thread.currentThread().interrupt();
          throw new SQLException("Interrupted attempting lock: " + this);
       }
    }

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -408,6 +408,7 @@
       }
       catch (InterruptedException e)
       {
+         Thread.currentThread().interrupt();
          throw new ResourceAllocationException("Interrupted attempting lock: " + this);
       }
    }

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -282,6 +282,7 @@
             }
             catch (InterruptedException e)
             {
+               Thread.currentThread().interrupt();
                log.debug("Interrupted trying to reconnect " + spec, e);
                break;
             }

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -51,7 +51,7 @@
    ConnectionConsumer consumer;
 
    /** The server sessions */
-   ArrayList serverSessions = new ArrayList();
+   final ArrayList serverSessions = new ArrayList();
    
    /** Whether the pool is stopped */
    boolean stopped = false;
@@ -105,7 +105,7 @@
          log.trace("getServerSession");
 
       ServerSession result = null;
-      
+      boolean intr = false;
       try
       {
          synchronized (serverSessions)
@@ -131,6 +131,7 @@
                   }
                   catch (InterruptedException ignored)
                   {
+                     intr = true;
                   }
                }
             }
@@ -140,7 +141,10 @@
       {
          throw new JMSException("Unable to get a server session " + t);
       }
-      
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
       if (trace)
          log.trace("Returning server session " + result);
       
@@ -203,64 +207,74 @@
     */
    protected void teardownSessions()
    {
-      synchronized (serverSessions)
+      boolean intr = false;
+      try
       {
-         // Disallow any new sessions
-         stopped = true;
-         serverSessions.notifyAll();
-         
-         // Stop inactive sessions
-         for (int i = 0; i < serverSessions.size(); ++i)
+         synchronized (serverSessions)
          {
-            JmsServerSession session = (JmsServerSession) serverSessions.get(i);
-            session.teardown();
-            --sessionCount;
-         }
+            // Disallow any new sessions
+            stopped = true;
+            serverSessions.notifyAll();
 
-         serverSessions.clear();
+            // Stop inactive sessions
+            for (int i = 0; i < serverSessions.size(); ++i)
+            {
+               JmsServerSession session = (JmsServerSession) serverSessions.get(i);
+               session.teardown();
+               --sessionCount;
+            }
 
-         if (activation.getActivationSpec().isForceClearOnShutdown())
-         {        
-            int attempts = 0;
-            int forceClearAttempts = activation.getActivationSpec().getForceClearAttempts();
-            long forceClearInterval = activation.getActivationSpec().getForceClearOnShutdownInterval();
-            
-            log.trace(this + " force clear behavior in effect. Waiting for " + forceClearInterval + " milliseconds for " + forceClearAttempts + " attempts.");
-           
-            while((sessionCount > 0) && (attempts < forceClearAttempts))
+            serverSessions.clear();
+
+            if (activation.getActivationSpec().isForceClearOnShutdown())
             {
-               try
+               int attempts = 0;
+               int forceClearAttempts = activation.getActivationSpec().getForceClearAttempts();
+               long forceClearInterval = activation.getActivationSpec().getForceClearOnShutdownInterval();
+
+               log.trace(this + " force clear behavior in effect. Waiting for " + forceClearInterval + " milliseconds for " + forceClearAttempts + " attempts.");
+
+               while((sessionCount > 0) && (attempts < forceClearAttempts))
                {
-                  int currentSessions = sessionCount;
-                  serverSessions.wait(forceClearInterval);
-                  // Number of session didn't change
-                  if (sessionCount == currentSessions)
+                  try
                   {
-                     ++attempts;
-                     log.trace(this + " clear attempt failed " + attempts); 
+                     int currentSessions = sessionCount;
+                     serverSessions.wait(forceClearInterval);
+                     // Number of session didn't change
+                     if (sessionCount == currentSessions)
+                     {
+                        ++attempts;
+                        log.trace(this + " clear attempt failed " + attempts);
+                     }
                   }
+                  catch(InterruptedException ignore)
+                  {
+                     intr = true;
+                  }
+
                }
-               catch(InterruptedException ignore)
-               {
-               }
-            
             }
-         }
-         else
-         {
-            // Wait for inuse sessions
-            while (sessionCount > 0)
+            else
             {
-               try
+               // Wait for inuse sessions
+               while (sessionCount > 0)
                {
-                  serverSessions.wait();
+                  try
+                  {
+                     serverSessions.wait();
+                  }
+                  catch (InterruptedException ignore)
+                  {
+                     intr = true;
+                  }
                }
-               catch (InterruptedException ignore)
-               {
-               }
             }
          }
       }
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
    }
    
    /**

Modified: trunk/connector/src/main/org/jboss/resource/adapter/mail/MailResourceAdapter.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/mail/MailResourceAdapter.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/mail/MailResourceAdapter.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -101,6 +101,7 @@
       }
       catch (InterruptedException e)
       {
+         Thread.currentThread().interrupt();
          throw new ResourceException("Failed to schedule new msg check", e);
       }
       activations.put(spec, activation);

Modified: trunk/connector/src/main/org/jboss/resource/adapter/mail/inflow/NewMsgsWorker.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/mail/inflow/NewMsgsWorker.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/adapter/mail/inflow/NewMsgsWorker.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -139,6 +139,7 @@
       }
       catch(InterruptedException ex)
       {
+         Thread.currentThread().interrupt();
          log.warn("Failed to reschedule new msg check", ex);
       }
    }

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -431,6 +431,7 @@
                }
                catch (InterruptedException e1)
                {
+                  Thread.currentThread().interrupt();
                   JBossResourceException.rethrowAsResourceException("getManagedConnection retry wait was interrupted " + jndiName, e1);
                }
             }

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/ConnectionValidator.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/ConnectionValidator.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/ConnectionValidator.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -170,6 +170,7 @@
                }
                catch (InterruptedException e)
                {
+                  Thread.currentThread().interrupt();
                   log.info("run: ConnectionValidator has been interrupted, returning");
                   return;  
                }

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/IdleRemover.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/IdleRemover.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/IdleRemover.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -175,8 +175,8 @@
                }
                catch (InterruptedException ie)
                {
-                  if (log.isDebugEnabled())
-                     log.debug("run: IdleRemover has been interrupted, ending");
+                  Thread.currentThread().interrupt();
+                  log.trace("run: IdleRemover has been interrupted, ending");
                   return;  
                }
                catch (RuntimeException e)

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -309,6 +309,7 @@
       }
       catch (InterruptedException ie)
       {
+         Thread.currentThread().interrupt();
          long end = System.currentTimeMillis() - startWait;
          connectionCounter.updateBlockTime(end);
          throw new ResourceException("Interrupted while requesting permit! Waited " + end + " ms");
@@ -518,51 +519,60 @@
 
    public void fillToMin()
    {
-      while (true)
+      boolean intr = false;
+      try
       {
-         // Get a permit - avoids a race when the pool is nearly full
-         // Also avoids unnessary fill checking when all connections are checked out
-         try
+         while (true)
          {
-            if (permits.tryAcquire(poolParams.blockingTimeout, TimeUnit.MILLISECONDS))
+            // Get a permit - avoids a race when the pool is nearly full
+            // Also avoids unnessary fill checking when all connections are checked out
+            try
             {
-               try
+               if (permits.tryAcquire(poolParams.blockingTimeout, TimeUnit.MILLISECONDS))
                {
-                  if (shutdown.get())
-                     return;
+                  try
+                  {
+                     if (shutdown.get())
+                        return;
 
-                  // We already have enough connections
-                  if (getMinSize() - connectionCounter.getGuaranteedCount() <= 0)
-                     return;
+                     // We already have enough connections
+                     if (getMinSize() - connectionCounter.getGuaranteedCount() <= 0)
+                        return;
 
-                  // Create a connection to fill the pool
-                  try
-                  {
-                     ConnectionListener cl = createConnectionEventListener(defaultSubject, defaultCri);
-                     synchronized (cls)
+                     // Create a connection to fill the pool
+                     try
                      {
-                        if (trace)
-                           log.trace("Filling pool cl=" + cl);
-                        cls.add(cl);
+                        ConnectionListener cl = createConnectionEventListener(defaultSubject, defaultCri);
+                        synchronized (cls)
+                        {
+                           if (trace)
+                              log.trace("Filling pool cl=" + cl);
+                           cls.add(cl);
+                        }
                      }
+                     catch (ResourceException re)
+                     {
+                        log.warn("Unable to fill pool ", re);
+                        return;
+                     }
                   }
-                  catch (ResourceException re)
+                  finally
                   {
-                     log.warn("Unable to fill pool ", re);
-                     return;
+                     permits.release();
                   }
                }
-               finally
-               {
-                  permits.release();
-               }
             }
+            catch (InterruptedException ignored)
+            {
+               intr = true;
+               log.trace("Interrupted while requesting permit in fillToMin");
+            }
          }
-         catch (InterruptedException ignored)
-         {
-            log.trace("Interrupted while requesting permit in fillToMin");
-         }
       }
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
    }
 
    public int getConnectionCount()

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/PoolFiller.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/PoolFiller.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/PoolFiller.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -91,6 +91,7 @@
          }
          catch (InterruptedException ie)
          {
+            Thread.currentThread().interrupt();
             return;
          }
       }

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/TransactionSynchronizer.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/TransactionSynchronizer.java	2009-05-20 03:13:48 UTC (rev 89153)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/TransactionSynchronizer.java	2009-05-20 03:14:06 UTC (rev 89154)
@@ -103,25 +103,31 @@
    synchronized ArrayList getUnenlisted()
    {
       Thread currentThread = Thread.currentThread();
-      while (enlistingThread != null && enlistingThread != currentThread)
+      boolean interrupted = false;
+      try
       {
-         boolean interrupted = false;
-         try
+         while (enlistingThread != null && enlistingThread != currentThread)
          {
-            wait();
+            try
+            {
+               wait();
+            }
+            catch (InterruptedException e)
+            {
+               interrupted = true;
+            }
          }
-         catch (InterruptedException e)
-         {
-            interrupted = true;
-         }
+         ArrayList result = unenlisted;
+         unenlisted = null;
+         if (result != null)
+            enlistingThread = currentThread;
+         return result;
+      }
+      finally
+      {
          if (interrupted)
             currentThread.interrupt();
       }
-      ArrayList result = unenlisted;
-      unenlisted = null;
-      if (result != null)
-         enlistingThread = currentThread;
-      return result;
    }
    
    /**
@@ -223,6 +229,7 @@
       }
       catch (InterruptedException e)
       {
+         Thread.currentThread().interrupt();
          throw new NestedRuntimeException("Unable to get synchronization", e);
       }
    }




More information about the jboss-cvs-commits mailing list