[jboss-cvs] JBoss Messaging SVN: r8375 - in branches/Branch_1_4/src/main/org/jboss: messaging/util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 4 06:45:17 EDT 2011


Author: gaohoward
Date: 2011-07-04 06:45:17 -0400 (Mon, 04 Jul 2011)
New Revision: 8375

Added:
   branches/Branch_1_4/src/main/org/jboss/messaging/util/StatefulRunnable.java
Modified:
   branches/Branch_1_4/src/main/org/jboss/jms/client/container/ClientConsumer.java
   branches/Branch_1_4/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
Log:
JBMESSAGING-1883


Modified: branches/Branch_1_4/src/main/org/jboss/jms/client/container/ClientConsumer.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/client/container/ClientConsumer.java	2011-06-28 21:00:47 UTC (rev 8374)
+++ branches/Branch_1_4/src/main/org/jboss/jms/client/container/ClientConsumer.java	2011-07-04 10:45:17 UTC (rev 8375)
@@ -50,6 +50,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.contract.Message;
 import org.jboss.messaging.util.Future;
+import org.jboss.messaging.util.StatefulRunnable;
 import org.jboss.messaging.util.prioritylinkedlist.BasicPriorityLinkedList;
 import org.jboss.messaging.util.prioritylinkedlist.PriorityLinkedList;
 
@@ -934,10 +935,20 @@
 
       Future result = new Future();
 
-      sessionExecutor.execute(new Closer(result));
+      Closer closer = new Closer(result);
+      sessionExecutor.execute(closer);
 
-      if (trace) { log.trace(this + " blocking wait for Closer execution"); }
-      result.getResult();
+      //https://issues.jboss.org/browse/JBMESSAGING-1883
+      if (closer.getState() == StatefulRunnable.NORMAL)
+      {
+         if (trace) { log.trace(this + " blocking wait for Closer execution"); }
+         result.getResult();
+      }
+      else
+      {
+         if (trace) { log.trace(this + " won't wait for Closer as the executor is closed already"); }
+      }
+      
       if (trace) { log.trace(this + " got Closer result"); }
    }
 
@@ -1086,7 +1097,7 @@
     * This class is used to put on the listener executor to wait for onMessage
     * invocations to complete when closing
     */
-   private class Closer implements Runnable
+   private class Closer extends StatefulRunnable
    {
       Future result;
       

Modified: branches/Branch_1_4/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2011-06-28 21:00:47 UTC (rev 8374)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2011-07-04 10:45:17 UTC (rev 8375)
@@ -82,6 +82,13 @@
                   parent.execute(this);
                }
             }
+            else
+            {
+               if (command instanceof StatefulRunnable)
+               {
+                  ((StatefulRunnable)command).setState(StatefulRunnable.NOT_SCHEDULED);
+               }
+            }
          }
       }
 

Added: branches/Branch_1_4/src/main/org/jboss/messaging/util/StatefulRunnable.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/util/StatefulRunnable.java	                        (rev 0)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/util/StatefulRunnable.java	2011-07-04 10:45:17 UTC (rev 8375)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2011, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.util;
+
+/**
+ * A StatefulRunnable: A Runnable that can be set a state
+ * 
+ * Created Jul 4, 2011 11:57:32 AM
+ *
+ *
+ */
+public abstract class StatefulRunnable implements Runnable
+{
+   public static final int NORMAL = 0;
+   public static final int NOT_SCHEDULED = -1;
+   
+   private volatile int state = NORMAL;
+
+   public void setState(int state)
+   {
+      this.state = state;
+   }
+   
+   public int getState()
+   {
+      return state;
+   }
+}



More information about the jboss-cvs-commits mailing list