You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2013/01/10 22:27:48 UTC

svn commit: r1431660 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java

Author: gtully
Date: Thu Jan 10 21:27:47 2013
New Revision: 1431660

URL: http://svn.apache.org/viewvc?rev=1431660&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4248 - ensure iter is cleared when we are done, i.e. on call to release

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java?rev=1431660&r1=1431659&r2=1431660&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java (original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java Thu Jan 10 21:27:47 2013
@@ -148,6 +148,8 @@ public class FilePendingMessageCursor ex
                 flushToDisk();
             }
         }
+        // ensure any memory ref is released
+        iter = null;
     }
 
     @Override

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java?rev=1431660&r1=1431659&r2=1431660&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java Thu Jan 10 21:27:47 2013
@@ -26,10 +26,9 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 public class FilePendingMessageCursorTestSupport {
 
@@ -70,4 +69,21 @@ public class FilePendingMessageCursorTes
         assertFalse("cursor is not full", underTest.isFull());
     }
 
+    @Test
+    public void testResetClearsIterator() throws Exception {
+        createBrokerWithTempStoreLimit();
+
+        underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
+        // ok to add
+        underTest.addMessageLast(QueueMessageReference.NULL_MESSAGE);
+
+        underTest.reset();
+        underTest.release();
+
+        try {
+            underTest.hasNext();
+            fail("expect npe on use of iterator after release");
+        } catch (NullPointerException expected) {}
+    }
+
 }