diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java index f5d49cf35a..23f01f9577 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java @@ -53,11 +53,11 @@ public class PagedReferenceImpl extends LinkedListImpl.Node private Object protocolData; - private final boolean largeMessage; + private Boolean largeMessage; - private final long transactionID; + private long transactionID = -1; - private final long messageID; + private long messageID = -1; private long messageSize = -1; @@ -103,12 +103,19 @@ public class PagedReferenceImpl extends LinkedListImpl.Node this.position = position; this.message = new WeakReference<>(message); this.subscription = subscription; - this.largeMessage = message.getMessage().isLargeMessage(); - this.transactionID = message.getTransactionID(); - this.messageID = message.getMessage().getMessageID(); + if (message != null) { + this.largeMessage = message.getMessage().isLargeMessage(); + this.transactionID = message.getTransactionID(); + this.messageID = message.getMessage().getMessageID(); - //pre-cache the message size so we don't have to reload the message later if it is GC'd - getPersistentSize(); + //pre-cache the message size so we don't have to reload the message later if it is GC'd + getPersistentSize(); + } else { + this.largeMessage = null; + this.transactionID = -1; + this.messageID = -1; + this.messageSize = -1; + } } @Override @@ -272,16 +279,25 @@ public class PagedReferenceImpl extends LinkedListImpl.Node @Override public boolean isLargeMessage() { + if (largeMessage == null && message != null) { + largeMessage = getMessage().isLargeMessage(); + } return largeMessage; } @Override public long getTransactionID() { + if (transactionID < 0) { + transactionID = getPagedMessage().getTransactionID(); + } return transactionID; } @Override public long getMessageID() { + if (messageID < 0) { + messageID = getPagedMessage().getMessage().getMessageID(); + } return messageID; }