gemmellr commented on code in PR #4101:
URL: https://github.com/apache/activemq-artemis/pull/4101#discussion_r895806513
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageEventMessage.java:
##########
@@ -32,43 +32,59 @@ public class ReplicationPageEventMessage extends PacketImpl
{
*/
private boolean isDelete;
- public ReplicationPageEventMessage() {
+ private final boolean useLong;
+
+ public ReplicationPageEventMessage(boolean useLong) {
super(PacketImpl.REPLICATION_PAGE_EVENT);
+ this.useLong = useLong;
}
- public ReplicationPageEventMessage(final SimpleString storeName, final int
pageNumber, final boolean isDelete) {
- this();
+ public ReplicationPageEventMessage(final SimpleString storeName, final long
pageNumber, final boolean isDelete, final boolean useLong) {
+ this(useLong);
this.pageNumber = pageNumber;
this.isDelete = isDelete;
this.storeName = storeName;
}
@Override
public int expectedEncodeSize() {
- return PACKET_HEADERS_SIZE +
- SimpleString.sizeofString(storeName) + //
buffer.writeSimpleString(storeName);
- DataConstants.SIZE_INT + // buffer.writeInt(pageNumber);
- DataConstants.SIZE_BOOLEAN; // buffer.writeBoolean(isDelete);
+ if (useLong) {
+ return PACKET_HEADERS_SIZE + SimpleString.sizeofString(storeName) +
// buffer.writeSimpleString(storeName);
+ DataConstants.SIZE_LONG + // buffer.writeLong(pageNumber);
+ DataConstants.SIZE_BOOLEAN; // buffer.writeBoolean(isDelete);
+ } else {
+ return PACKET_HEADERS_SIZE + SimpleString.sizeofString(storeName) +
// buffer.writeSimpleString(storeName);
+ DataConstants.SIZE_INT + // buffer.writeInt(pageNumber);
+ DataConstants.SIZE_BOOLEAN; // buffer.writeBoolean(isDelete);
+ }
}
@Override
public void encodeRest(final ActiveMQBuffer buffer) {
buffer.writeSimpleString(storeName);
- buffer.writeInt(pageNumber);
+ if (useLong) {
+ buffer.writeLong(pageNumber);
+ } else {
+ buffer.writeInt((int) pageNumber);
Review Comment:
Users always find a way to hit such things when assuming they wont. It
doesnt seem anywhere near impossible to me. This is trivial to validate now and
fail-fast later, but will be a nightmare to identify later if hit without doing
so. It seems pointless not to just cover the situation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]