Author: clebert.suconic(a)jboss.com
Date: 2010-11-10 12:28:31 -0500 (Wed, 10 Nov 2010)
New Revision: 9865
Modified:
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java
Log:
fixing deadlock
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-10
02:49:26 UTC (rev 9864)
+++
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/cursor/impl/PageSubscriptionImpl.java 2010-11-10
17:28:31 UTC (rev 9865)
@@ -167,23 +167,35 @@
class CursorIterator implements LinkedListIterator<PagedReference>
{
- PagePosition position = null;
+ private PagePosition position = null;
- PagePosition lastOperation = null;
+ private PagePosition lastOperation = null;
- LinkedListIterator<PagePosition> redeliveryIterator =
redeliveries.iterator();
+ private final LinkedListIterator<PagePosition> redeliveryIterator;
- boolean isredelivery = false;
+ private volatile boolean isredelivery = false;
/** next element taken on hasNext test.
* it has to be delivered on next next operation */
- PagedReference cachedNext;
+ private volatile PagedReference cachedNext;
+
+ public CursorIterator()
+ {
+ synchronized (redeliveries)
+ {
+ redeliveryIterator = redeliveries.iterator();
+ }
+ }
+
public void repeat()
{
if (isredelivery)
{
- redeliveryIterator.repeat();
+ synchronized (redeliveries)
+ {
+ redeliveryIterator.repeat();
+ }
}
else
{
@@ -214,16 +226,19 @@
try
{
- if (redeliveryIterator.hasNext())
+ synchronized (redeliveries)
{
- // There's a redelivery pending, we will get it out of that pool
instead
- isredelivery = true;
- return getReference(redeliveryIterator.next());
+ if (redeliveryIterator.hasNext())
+ {
+ // There's a redelivery pending, we will get it out of that pool
instead
+ isredelivery = true;
+ return getReference(redeliveryIterator.next());
+ }
+ else
+ {
+ isredelivery = false;
+ }
}
- else
- {
- isredelivery = false;
- }
if (position == null)
{
@@ -448,9 +463,12 @@
/* (non-Javadoc)
* @see
org.hornetq.core.paging.cursor.PageCursor#returnElement(org.hornetq.core.paging.cursor.PagePosition)
*/
- public synchronized void redeliver(final PagePosition position)
+ public void redeliver(final PagePosition position)
{
- redeliveries.addTail(position);
+ synchronized (redeliveries)
+ {
+ redeliveries.addTail(position);
+ }
}
/**