[hornetq-commits] JBoss hornetq SVN: r9830 - branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Nov 1 20:38:52 EDT 2010
Author: clebert.suconic at jboss.com
Date: 2010-11-01 20:38:52 -0400 (Mon, 01 Nov 2010)
New Revision: 9830
Modified:
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java
Log:
tweak
Modified: branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java
===================================================================
--- branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java 2010-11-02 00:24:34 UTC (rev 9829)
+++ branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java 2010-11-02 00:38:52 UTC (rev 9830)
@@ -160,6 +160,10 @@
LinkedListIterator<PagePosition> redeliveryIterator = redeliveries.iterator();
boolean isredelivery = false;
+
+ /** next element taken on hasNext test.
+ * it has to be delivered on next next operation */
+ Pair<PagePosition, PagedMessage> cachedNext;
public void repeat()
{
@@ -185,6 +189,13 @@
*/
public Pair<PagePosition, PagedMessage> next()
{
+
+ if (cachedNext != null)
+ {
+ Pair<PagePosition, PagedMessage> retPos = cachedNext;
+ cachedNext = null;
+ return retPos;
+ }
try
{
if (redeliveryIterator.hasNext())
@@ -212,7 +223,15 @@
public boolean hasNext()
{
- return true;
+ // if an unbehaved program called hasNext twice before next, we only cache it once.
+ if (cachedNext != null)
+ {
+ return true;
+ }
+
+ cachedNext = next();
+
+ return cachedNext != null;
}
/* (non-Javadoc)
More information about the hornetq-commits
mailing list