[jboss-cvs] JBossAS SVN: r89152 - in trunk/server/src/main/org/jboss: ejb/plugins/cmp/jdbc2/schema and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 19 23:11:09 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-05-19 23:11:09 -0400 (Tue, 19 May 2009)
New Revision: 89152

Modified:
   trunk/server/src/main/org/jboss/ejb/plugins/MetricsInterceptor.java
   trunk/server/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
   trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
   trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
   trunk/server/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java
   trunk/server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
   trunk/server/src/main/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
   trunk/server/src/main/org/jboss/invocation/jrmp/server/JRMPInvoker.java
   trunk/server/src/main/org/jboss/invocation/pooled/server/ServerThread.java
   trunk/server/src/main/org/jboss/invocation/unified/server/UnifiedInvoker.java
   trunk/server/src/main/org/jboss/logging/Log4jSocketServer.java
Log:
JBAS-6957 - wrong interrupt handling

Modified: trunk/server/src/main/org/jboss/ejb/plugins/MetricsInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/MetricsInterceptor.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/MetricsInterceptor.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -255,7 +255,7 @@
        */
       public void run()
       {
-
+         boolean intr = false;
          try
          {
             final boolean IS_TRANSACTED = true;
@@ -335,6 +335,7 @@
                catch (InterruptedException e)
                {
                   // kill this thread
+                  intr = true;
                   running = false;
                }
             }
@@ -364,6 +365,10 @@
             {
                 log.warn(e);
             }
+            finally
+            {
+               if (intr) Thread.currentThread().interrupt();
+            }
          }
       }
    }

Modified: trunk/server/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -61,33 +61,41 @@
    public synchronized EnterpriseContext get()
       throws Exception
    {
-      // Wait while someone else is using it
-      while(inUse && isSynchronized)
+      boolean intr = false;
+      try
       {
-         try { this.wait(); } catch (InterruptedException e) {}
-      }
+         // Wait while someone else is using it
+         while(inUse && isSynchronized)
+         {
+            try { this.wait(); } catch (InterruptedException e) { intr = true; }
+         }
 
-      // Create if not already created (or it has been discarded)
-      if (ctx == null)
-      {
-         try
+         // Create if not already created (or it has been discarded)
+         if (ctx == null)
          {
-            ctx = create(getContainer().createBeanClassInstance());
-         } catch (InstantiationException e)
+            try
+            {
+               ctx = create(getContainer().createBeanClassInstance());
+            } catch (InstantiationException e)
+            {
+               throw new EJBException("Could not instantiate bean", e);
+            } catch (IllegalAccessException e)
+            {
+               throw new EJBException("Could not instantiate bean", e);
+            }
+         }
+         else
          {
-            throw new EJBException("Could not instantiate bean", e);
-         } catch (IllegalAccessException e)
-         {
-            throw new EJBException("Could not instantiate bean", e);
          }
+
+         // Lock and return instance
+         inUse = true;
+         return ctx;
       }
-      else
+      finally
       {
+         if (intr) Thread.currentThread().interrupt();
       }
-
-      // Lock and return instance
-      inUse = true;
-      return ctx;
    }
 
    /**

Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -276,22 +276,31 @@
 
       public void run()
       {
-         while(run)
+         boolean intr = false;
+         try
          {
-            long lastUpdated = System.currentTimeMillis() - maxAgeMs;
-            for(int i = 0; i < partitions.length; ++i)
+            while(run)
             {
-               partitions[i].ageOut(lastUpdated);
-            }
+               long lastUpdated = System.currentTimeMillis() - maxAgeMs;
+               for(int i = 0; i < partitions.length; ++i)
+               {
+                  partitions[i].ageOut(lastUpdated);
+               }
 
-            try
-            {
-               Thread.sleep(periodMs);
+               try
+               {
+                  Thread.sleep(periodMs);
+               }
+               catch(InterruptedException e)
+               {
+                  intr = true;
+               }
             }
-            catch(InterruptedException e)
-            {
-            }
          }
+         finally
+         {
+            if (intr) Thread.currentThread().interrupt();
+         }
       }
    }
 }

Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -127,23 +127,32 @@
 
    public synchronized void lock()
    {
-      if(locked)
+      boolean intr = false;
+      try
       {
-         long start = System.currentTimeMillis();
-         while(locked)
+         if(locked)
          {
-            try
+            long start = System.currentTimeMillis();
+            while(locked)
             {
-               wait();
+               try
+               {
+                  wait();
+               }
+               catch(InterruptedException e)
+               {
+                  intr = true;
+               }
             }
-            catch(InterruptedException e)
-            {
-            }
+
+            listener.contention(partitionIndex, System.currentTimeMillis() - start);
          }
-
-         listener.contention(partitionIndex, System.currentTimeMillis() - start);
+         locked = true;
       }
-      locked = true;
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
    }
 
    public void lock(Object key)

Modified: trunk/server/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -100,20 +100,31 @@
     */ 
    public void sync()
    {
-      synchronized(this)
+      boolean intr = false;
+      try
       {
-         Thread thread = Thread.currentThread();
-         while(synched != null && synched.equals(thread) == false)
+         synchronized(this)
          {
-            try
+            Thread thread = Thread.currentThread();
+            while(synched != null && synched.equals(thread) == false)
             {
-               this.wait();
+               try
+               {
+                  wait();
+               }
+               catch (InterruptedException ex)
+               {
+                  intr = true;
+               }
             }
-            catch (InterruptedException ex) { /* ignore */ }
+            synched = thread;
+            ++synchedDepth;
          }
-         synched = thread;
-         ++synchedDepth;
       }
+      finally
+      {
+         if (intr) Thread.currentThread().interrupt();
+      }
    }
  
    public void releaseSync()

Modified: trunk/server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -272,98 +272,107 @@
     */
    protected boolean waitForTx(Transaction miTx, boolean trace) throws Exception
    {
-      boolean wasScheduled = false;
-      // Do we have a running transaction with the context?
-      // We loop here until either until success or until transaction timeout
-      // If we get out of the loop successfully, we can successfully
-      // set the transaction on this puppy.
-      TxLock txLock = null;
-      Object deadlocker = miTx;
-      if (deadlocker == null) deadlocker = Thread.currentThread();
+      boolean intr = false;
+      try
+      {
+         boolean wasScheduled = false;
+         // Do we have a running transaction with the context?
+         // We loop here until either until success or until transaction timeout
+         // If we get out of the loop successfully, we can successfully
+         // set the transaction on this puppy.
+         TxLock txLock = null;
+         Object deadlocker = miTx;
+         if (deadlocker == null) deadlocker = Thread.currentThread();
 
-      while (getTransaction() != null &&
-              // And are we trying to enter with another transaction?
-              !getTransaction().equals(miTx))
-      {
-         // Check for a deadlock on every cycle
-         try
+         while (getTransaction() != null &&
+                 // And are we trying to enter with another transaction?
+                 !getTransaction().equals(miTx))
          {
-            if( deadlockDetection == true )
-               DeadlockDetector.singleton.deadlockDetection(deadlocker, this);
-         }
-         catch (Exception e)
-         {
-            // We were queued, not any more
-            if (txLock != null && txLock.isQueued)
+            // Check for a deadlock on every cycle
+            try
             {
-               txLocks.remove(txLock);
-               txWaitQueue.remove(txLock);
+               if( deadlockDetection == true )
+                  DeadlockDetector.singleton.deadlockDetection(deadlocker, this);
             }
-            throw e;
-         }
+            catch (Exception e)
+            {
+               // We were queued, not any more
+               if (txLock != null && txLock.isQueued)
+               {
+                  txLocks.remove(txLock);
+                  txWaitQueue.remove(txLock);
+               }
+               throw e;
+            }
 
-         wasScheduled = true;
-         if (lockMonitor != null) lockMonitor.contending();
-         // That's no good, only one transaction per context
-         // Let's put the thread to sleep the transaction demarcation will wake them up
-         if (trace) log.trace("Transactional contention on context" + id);
+            wasScheduled = true;
+            if (lockMonitor != null) lockMonitor.contending();
+            // That's no good, only one transaction per context
+            // Let's put the thread to sleep the transaction demarcation will wake them up
+            if (trace) log.trace("Transactional contention on context" + id);
 
-         // Only queue the lock on the first iteration
-         if (txLock == null)
-            txLock = getTxLock(miTx);
+            // Only queue the lock on the first iteration
+            if (txLock == null)
+               txLock = getTxLock(miTx);
 
-         if (trace) log.trace("Begin wait on Tx=" + getTransaction());
+            if (trace) log.trace("Begin wait on Tx=" + getTransaction());
 
-         // And lock the threads on the lock corresponding to the Tx in MI
-         synchronized (txLock)
-         {
-            releaseSync();
-            try
+            // And lock the threads on the lock corresponding to the Tx in MI
+            synchronized (txLock)
             {
-               txLock.wait(txTimeout);
-            }
-            catch (InterruptedException ignored)
+               releaseSync();
+               try
+               {
+                  txLock.wait(txTimeout);
+               }
+               catch (InterruptedException ignored)
+               {
+                  intr = true;
+               }
+            } // end synchronized(txLock)
+
+            this.sync();
+
+            if (trace) log.trace("End wait on TxLock=" + getTransaction());
+            if (isTxExpired(miTx))
             {
+               log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock"
+                       // +" On method: " + mi.getMethod().getName()
+                       // +" txWaitQueue size: " + txWaitQueue.size()
+               );
+               if (txLock.isQueued)
+               {
+                  // Remove the TxLock from the queue because this thread is exiting.
+                  // Don't worry about notifying other threads that share the same transaction.
+                  // They will timeout and throw the below RuntimeException
+                  txLocks.remove(txLock);
+                  txWaitQueue.remove(txLock);
+               }
+               else if (getTransaction() != null && getTransaction().equals(miTx))
+               {
+                  // We're not qu
+                  nextTransaction();
+               }
+               if (miTx != null)
+               {
+                  if( deadlockDetection == true )
+                     DeadlockDetector.singleton.removeWaiting(deadlocker);
+               }
+               throw new RuntimeException("Transaction marked for rollback, possibly a timeout");
             }
-         } // end synchronized(txLock)
+         } // end while(tx!=miTx)
 
-         this.sync();
-
-         if (trace) log.trace("End wait on TxLock=" + getTransaction());
-         if (isTxExpired(miTx))
+         // If we get here, this means that we have the txlock
+         if (!wasScheduled)
          {
-            log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock"
-                    // +" On method: " + mi.getMethod().getName()
-                    // +" txWaitQueue size: " + txWaitQueue.size()
-            );
-            if (txLock.isQueued)
-            {
-               // Remove the TxLock from the queue because this thread is exiting.
-               // Don't worry about notifying other threads that share the same transaction.
-               // They will timeout and throw the below RuntimeException
-               txLocks.remove(txLock);
-               txWaitQueue.remove(txLock);
-            }
-            else if (getTransaction() != null && getTransaction().equals(miTx))
-            {
-               // We're not qu
-               nextTransaction();
-            }
-            if (miTx != null)
-            {
-               if( deadlockDetection == true )
-                  DeadlockDetector.singleton.removeWaiting(deadlocker);
-            }
-            throw new RuntimeException("Transaction marked for rollback, possibly a timeout");
+            setTransaction(miTx);
          }
-      } // end while(tx!=miTx)
-
-      // If we get here, this means that we have the txlock
-      if (!wasScheduled)
+         return wasScheduled;
+      }
+      finally
       {
-         setTransaction(miTx);
+         if (intr) Thread.currentThread().interrupt();
       }
-      return wasScheduled;
    }
 
    /*

Modified: trunk/server/src/main/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -21,14 +21,10 @@
  */
 package org.jboss.ejb.plugins.lock;
 
-import java.util.LinkedList;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Stack;
-import java.util.Collections;
 import java.lang.reflect.Method;
 
-import javax.ejb.EJBObject;
 import javax.ejb.EJBException;
 import javax.transaction.Status;
 import javax.transaction.Transaction;
@@ -63,7 +59,7 @@
     int writersWaiting = 0;
     Transaction promotingReader = null;
     Transaction writer = null;
-    HashSet readers = new HashSet();
+    final HashSet readers = new HashSet();
     Object methodLock = new Object();
     boolean trace = log.isTraceEnabled();
 
@@ -205,24 +201,26 @@
      */
     private void waitAWhile(Transaction tx)
     {
-	releaseSync();
-	try
-	{
-	    synchronized(readers)
-	    {
-		try
-		{
-		    readers.wait(txTimeout);
-		}
-		catch(InterruptedException e)
-		{}
-		checkTransaction(tx);
-	    }
-	}
-	finally
-	{
-	    sync();
-	}
+       releaseSync();
+       try
+       {
+          synchronized (readers)
+          {
+             try
+             {
+                readers.wait(txTimeout);
+             }
+             catch (InterruptedException e)
+             {
+                Thread.currentThread().interrupt();
+             }
+             checkTransaction(tx);
+          }
+       }
+       finally
+       {
+          sync();
+       }
     }
     
     /**

Modified: trunk/server/src/main/org/jboss/invocation/jrmp/server/JRMPInvoker.java
===================================================================
--- trunk/server/src/main/org/jboss/invocation/jrmp/server/JRMPInvoker.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/invocation/jrmp/server/JRMPInvoker.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -439,7 +439,6 @@
       finally
       {
          TCLAction.UTIL.setContextClassLoader(oldCl);
-         Thread.interrupted(); // clear interruption because this thread may be pooled.
       }
    }
 

Modified: trunk/server/src/main/org/jboss/invocation/pooled/server/ServerThread.java
===================================================================
--- trunk/server/src/main/org/jboss/invocation/pooled/server/ServerThread.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/invocation/pooled/server/ServerThread.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -21,11 +21,7 @@
  */
 package org.jboss.invocation.pooled.server;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.InterruptedIOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.*;
 import java.net.Socket;
 import java.util.LinkedList;
 
@@ -48,6 +44,9 @@
  * *NOTES* ObjectStreams were found to be better performing than the Custom marshalling
  * done by the TrunkInvoker.
  *
+ * NOTE: The interrupt handling surrounding shutdown appears rather f**ked but I don't see an easy way to fix it,
+ * so I'm leaving it for now.
+ *
  * @author    <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author Scott.Stark at jboss.org
  * @version $Revision$
@@ -221,31 +220,45 @@
 
    protected void processInvocation() throws Exception
    {
-      handlingResponse = true;
-      // Ok, now read invocation and invoke
-      Invocation invocation = (Invocation)in.readObject();
-      in.readObject(); // for stupid ObjectInputStream reset
-      Object response = null;
+      // this is a best-effort attempt to avoid being interrupted, but as interruption can happen at any
+      // time, this is not bullet-proof
+      boolean interrupted = Thread.interrupted();
       try
       {
-          // Make absolutely sure thread interrupted is cleared.
-         boolean interrupted = Thread.interrupted();
-         response = invoker.invoke(invocation);
+         handlingResponse = true;
+         // Ok, now read invocation and invoke
+         Invocation invocation = (Invocation)in.readObject();
+         in.readObject(); // for stupid ObjectInputStream reset
+         Object response = null;
+         try
+         {
+             // Make absolutely sure thread interrupted is cleared.
+            response = invoker.invoke(invocation);
+         }
+         catch (InterruptedException ex)
+         {
+            interrupted = true;
+            response = new IllegalStateException("Thread was interrupted");
+         }
+         catch (Exception ex)
+         {
+            response = ex;
+         }
+         interrupted |= Thread.interrupted(); // clear interrupted state so we don't fail on socket writes
+         out.writeObject(response);
+         out.reset();
+         // to make sure stream gets reset
+         // Stupid ObjectInputStream holds object graph
+         // can only be set by the client/server sending a TC_RESET
+         out.writeObject(Boolean.TRUE);
+         out.flush();
+         out.reset();
+         handlingResponse = false;
       }
-      catch (Exception ex)
+      finally
       {
-         response = ex;
+         if (interrupted) Thread.currentThread().interrupt();
       }
-      Thread.interrupted(); // clear interrupted state so we don't fail on socket writes
-      out.writeObject(response);
-      out.reset();
-      // to make sure stream gets reset
-      // Stupid ObjectInputStream holds object graph
-      // can only be set by the client/server sending a TC_RESET
-      out.writeObject(Boolean.TRUE); 
-      out.flush();
-      out.reset();
-      handlingResponse = false;
    }
 
    /**
@@ -253,82 +266,97 @@
     */
    protected void dorun()
    {
-      log.debug("beginning dorun");
-      running = true;
-      handlingResponse = true;
+      boolean intr = false;
       try
       {
-         BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
-         out = new OptimizedObjectOutputStream(bos);
-         out.flush();
-         BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
-         in = new OptimizedObjectInputStream(bis);
-      }
-      catch (Exception e)
-      {
-         log.error("Failed to initialize", e);
-      }
+         log.debug("beginning dorun");
+         running = true;
+         handlingResponse = true;
+         try
+         {
+            BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
+            out = new OptimizedObjectOutputStream(bos);
+            out.flush();
+            BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
+            in = new OptimizedObjectInputStream(bis);
+         }
+         catch (Exception e)
+         {
+            log.error("Failed to initialize", e);
+         }
 
-      // Always do first one without an ACK because its not needed
-      try
-      {
-         processInvocation();
-      }
-      catch (Exception e)
-      {
-         running = false;
-         if( trace )
-            log.trace("invocation failed", e);
-      }
-
-      // Re-use loop
-      while (running)
-      {
+         // Always do first one without an ACK because its not needed
          try
          {
-            acknowledge();
             processInvocation();
          }
-         catch (InterruptedIOException e)
-         {
-            log.debug("socket timed out", e);
-            running = false;
-         }
          catch (InterruptedException e)
          {
+            intr = true;
             log.debug("interrupted", e);
          }
-         catch (Exception ex)
+         catch (Exception e)
          {
+            running = false;
             if( trace )
-               log.debug("invocation failed", ex);
-            running = false;
+               log.trace("invocation failed", e);
          }
-         // clear any interruption so that thread can be pooled.
-         Thread.interrupted();
-      }
 
-      if( trace )
-         log.trace("finished loop");
-      // Ok, we've been shutdown.  Do appropriate cleanups.
-      try
-      {
-         if (in != null) in.close();
-         if (out != null) out.close();
+         // Re-use loop
+         while (running)
+         {
+            try
+            {
+               acknowledge();
+               processInvocation();
+            }
+            catch (InterruptedIOException e)
+            {
+               log.debug("socket timed out", e);
+               running = false;
+            }
+            catch (InterruptedException e)
+            {
+               intr = true;
+               log.debug("interrupted", e);
+            }
+            catch (Exception ex)
+            {
+               if( trace )
+                  log.debug("invocation failed", ex);
+               running = false;
+            }
+         }
+
+         if( trace )
+            log.trace("finished loop");
+         // Ok, we've been shutdown.  Do appropriate cleanups.
+         safeClose(in);
+         safeClose(out);
+         safeClose(socket);
+         socket = null;
+         in = null;
+         out = null;
       }
-      catch (Exception ex)
+      finally
       {
+         if (intr) Thread.currentThread().interrupt();
       }
-      try
-      {
-         socket.close();
+   }
+
+   private static void safeClose(Closeable c) {
+      if (c != null) try {
+         c.close();
+      } catch (Throwable t) {
+         log.error("Failed to close resource " + c, t);
       }
-      catch (Exception ex)
-      {
-         log.debug("Failed cleanup", ex);
+   }
+
+   private static void safeClose(Socket c) {
+      if (c != null) try {
+         c.close();
+      } catch (Throwable t) {
+         log.error("Failed to close resource " + c, t);
       }
-      socket = null;
-      in = null;
-      out = null;
    }
 }

Modified: trunk/server/src/main/org/jboss/invocation/unified/server/UnifiedInvoker.java
===================================================================
--- trunk/server/src/main/org/jboss/invocation/unified/server/UnifiedInvoker.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/invocation/unified/server/UnifiedInvoker.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -253,7 +253,6 @@
       finally
       {
          currentThread.setContextClassLoader(oldCl);
-         Thread.interrupted(); // clear interruption because this thread may be pooled.
       }
 
    }

Modified: trunk/server/src/main/org/jboss/logging/Log4jSocketServer.java
===================================================================
--- trunk/server/src/main/org/jboss/logging/Log4jSocketServer.java	2009-05-20 03:07:19 UTC (rev 89151)
+++ trunk/server/src/main/org/jboss/logging/Log4jSocketServer.java	2009-05-20 03:11:09 UTC (rev 89152)
@@ -219,33 +219,42 @@
       
       public void run()
       {
-         while (!shuttingDown)
+         boolean intr = false;
+         try
          {
-            
-            if (!enabled)
+            while (!shuttingDown)
             {
-               try
+
+               if (!enabled)
                {
-                  log.debug("Disabled, waiting for notification");
-                  synchronized (lock)
+                  try
                   {
-                     lock.wait();
+                     log.debug("Disabled, waiting for notification");
+                     synchronized (lock)
+                     {
+                        lock.wait();
+                     }
                   }
+                  catch (InterruptedException ignore)
+                  {
+                     intr = true;
+                  }
                }
-               catch (InterruptedException ignore)
+
+               try
                {
+                  doRun();
                }
+               catch (Throwable e)
+               {
+                  log.error("Exception caught from main loop; ignoring", e);
+               }
             }
-
-            try
-            {
-               doRun();
-            }
-            catch (Throwable e)
-            {
-               log.error("Exception caught from main loop; ignoring", e);
-            }
          }
+         finally
+         {
+            if (intr) Thread.currentThread().interrupt();
+         }
       }
 
       protected void doRun() throws Exception




More information about the jboss-cvs-commits mailing list