Author: jbertram
Date: 2012-02-21 17:54:57 -0500 (Tue, 21 Feb 2012)
New Revision: 12159
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/Branch_2_2_AS7/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_AS7/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
---
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-02-21
22:53:07 UTC (rev 12158)
+++
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-02-21
22:54:57 UTC (rev 12159)
@@ -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_AS7/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
---
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2012-02-21
22:53:07 UTC (rev 12158)
+++
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2012-02-21
22:54:57 UTC (rev 12159)
@@ -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();
Show replies by date