mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-03-01 06:49:25 +00:00
Fixing race on PageSubscriptionImpl
I have seen a NPE in a few unit tests that were caused by currenDelivery changing between these two steps: i - if (currentDelivery != null) ii - .... currentDelivery.getPos(); instead of adding extra synchronization I'm caching the currentValue what would been enough on this case. This is just to avoid NPEs
This commit is contained in:
parent
238b2fe094
commit
41b823be7e
@ -1471,12 +1471,13 @@ final class PageSubscriptionImpl implements PageSubscription
|
||||
public void remove()
|
||||
{
|
||||
deliveredCount.incrementAndGet();
|
||||
if (currentDelivery != null)
|
||||
PagedReference delivery = currentDelivery;
|
||||
if (delivery != null)
|
||||
{
|
||||
PageCursorInfo info = PageSubscriptionImpl.this.getPageInfo(currentDelivery.getPosition());
|
||||
PageCursorInfo info = PageSubscriptionImpl.this.getPageInfo(delivery.getPosition());
|
||||
if (info != null)
|
||||
{
|
||||
info.remove(currentDelivery.getPosition());
|
||||
info.remove(delivery.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user