mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-4248 - ensure iter is cleared when we are done, i.e. on call to release
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1431660 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7d2ac2d936
commit
109cbe0993
|
@ -148,6 +148,8 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||
flushToDisk();
|
||||
}
|
||||
}
|
||||
// ensure any memory ref is released
|
||||
iter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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 FilePendingMessageCursorTestSupport {
|
|||
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) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue