mirror of
https://github.com/apache/activemq.git
synced 2025-02-22 09:55:47 +00:00
Fixing PList size tracking by moving the null assignment on removal to after the onRemoval method is called to make sure that the decrement is done properly.
This commit is contained in:
parent
0706fd0bc1
commit
d635a36940
@ -358,7 +358,7 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
||||
|
||||
@Override
|
||||
public synchronized long messageSize() {
|
||||
return memoryList.messageSize() + (isDiskListEmpty() ? 0 : (int)getDiskList().messageSize());
|
||||
return memoryList.messageSize() + (isDiskListEmpty() ? 0 : getDiskList().messageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,7 +203,7 @@ public final class ListNode<Key, Value> {
|
||||
}
|
||||
try {
|
||||
entryToRemove.unlink();
|
||||
entryToRemove = null;
|
||||
|
||||
ListNode<Key, Value> toRemoveNode = null;
|
||||
if (currentNode.entries.isEmpty()) {
|
||||
// may need to free this node
|
||||
@ -237,7 +237,9 @@ public final class ListNode<Key, Value> {
|
||||
currentNode = previousNode;
|
||||
}
|
||||
}
|
||||
|
||||
targetList.onRemove(entryToRemove);
|
||||
entryToRemove = null;
|
||||
|
||||
if (toRemoveNode != null) {
|
||||
tx.free(toRemoveNode.getPage());
|
||||
|
@ -32,6 +32,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.store.PList;
|
||||
import org.apache.activemq.store.PList.PListIterator;
|
||||
import org.apache.activemq.store.PListEntry;
|
||||
import org.apache.activemq.util.ByteSequence;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
@ -74,6 +75,7 @@ public class PListTest {
|
||||
plist.addLast(test, bs);
|
||||
}
|
||||
assertEquals(plist.size(), COUNT);
|
||||
assertTrue(plist.messageSize() > 0);
|
||||
int count = 0;
|
||||
for (ByteSequence bs : map.values()) {
|
||||
String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
|
||||
@ -95,6 +97,7 @@ public class PListTest {
|
||||
plist.addFirst(test, bs);
|
||||
}
|
||||
assertEquals(plist.size(), COUNT);
|
||||
assertTrue(plist.messageSize() > 0);
|
||||
long count = plist.size() - 1;
|
||||
for (ByteSequence bs : map.values()) {
|
||||
String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
|
||||
@ -125,6 +128,7 @@ public class PListTest {
|
||||
entry = plist.getFirst();
|
||||
}
|
||||
assertEquals(0, plist.size());
|
||||
assertEquals(0, plist.messageSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -132,6 +136,7 @@ public class PListTest {
|
||||
doTestRemove(1);
|
||||
plist.destroy();
|
||||
assertEquals(0, plist.size());
|
||||
assertEquals(0, plist.messageSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -146,6 +151,7 @@ public class PListTest {
|
||||
}
|
||||
plist.destroy();
|
||||
assertEquals(0, plist.size());
|
||||
assertEquals(0, plist.messageSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user