[hornetq-commits] JBoss hornetq SVN: r12160 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/clientcrash and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Feb 21 17:59:15 EST 2012


Author: jbertram
Date: 2012-02-21 17:59:13 -0500 (Tue, 21 Feb 2012)
New Revision: 12160

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
Log:
[HORNETQ-865] Rollback for crashed client not updating delivery count properly

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java	2012-02-21 22:54:57 UTC (rev 12159)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java	2012-02-21 22:59:13 UTC (rev 12160)
@@ -291,7 +291,7 @@
 
          try
          {
-            rollback(false);
+            rollback(failed, false);
          }
          catch (Exception e)
          {
@@ -633,8 +633,19 @@
       }
    }
 
-   public synchronized void rollback(final boolean considerLastMessageAsDelivered) throws Exception
+   public void rollback(final boolean considerLastMessageAsDelivered) throws Exception
    {
+	   rollback(false, considerLastMessageAsDelivered);
+   }
+
+   /**
+    * 
+    * @param clientFailed If the client has failed, we can't decrease the delivery-counts, and the close may issue a rollback
+    * @param considerLastMessageAsDelivered
+    * @throws Exception
+    */
+   private synchronized void rollback(final boolean clientFailed, final boolean considerLastMessageAsDelivered) throws Exception
+   {
       if (tx == null)
       {
          // Might be null if XA
@@ -642,7 +653,7 @@
          tx = new TransactionImpl(storageManager, timeoutSeconds);
       }
 
-      doRollback(considerLastMessageAsDelivered, tx);
+      doRollback(clientFailed, considerLastMessageAsDelivered, tx);
 
       if (xa)
       {
@@ -871,7 +882,7 @@
             }
             else
             {
-               doRollback(false, theTx);
+               doRollback(false, false, theTx);
             }
          }
       }
@@ -1367,7 +1378,7 @@
       }
    }
 
-   private void doRollback(final boolean lastMessageAsDelived, final Transaction theTx) throws Exception
+   private void doRollback(final boolean clientFailed, final boolean lastMessageAsDelived, final Transaction theTx) throws Exception
    {
       boolean wasStarted = started;
 
@@ -1380,7 +1391,7 @@
             consumer.setStarted(false);
          }
 
-         toCancel.addAll(consumer.cancelRefs(false, lastMessageAsDelived, theTx));
+         toCancel.addAll(consumer.cancelRefs(clientFailed, lastMessageAsDelived, theTx));
       }
 
       for (MessageReference ref : toCancel)

Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java	2012-02-21 22:54:57 UTC (rev 12159)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java	2012-02-21 22:59:13 UTC (rev 12160)
@@ -143,7 +143,7 @@
       Assert.assertNotNull("no message received", messageFromClient);
       Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
 
-      assertEquals(1, messageFromClient.getDeliveryCount());
+      assertEquals(2, messageFromClient.getDeliveryCount());
       
       session.close();
 



More information about the hornetq-commits mailing list