Skip to content

Commit

Permalink
Fix typo of the returned last message ID when the last message ID is …
Browse files Browse the repository at this point in the history
…from compacted ledger (apache#12237)
  • Loading branch information
codelipenghui authored Sep 29, 2021
1 parent 2f3ad4d commit 102e3d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ public void readEntryFailed(ManagedLedgerException exception, Object ctx) {
int bs = metadata.getNumMessagesInBatch();
int largestBatchIndex = bs > 0 ? bs - 1 : -1;
ctx.writeAndFlush(Commands.newGetLastMessageIdResponse(requestId,
entry.getLedgerId(), entry.getLedgerId(), partitionIndex, largestBatchIndex,
entry.getLedgerId(), entry.getEntryId(), partitionIndex, largestBatchIndex,
markDeletePosition != null ? markDeletePosition.getLedgerId() : -1,
markDeletePosition != null ? markDeletePosition.getEntryId() : -1));
entry.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.apache.pulsar.client.api.Reader;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.impl.RawMessageImpl;
import org.apache.pulsar.client.impl.ReaderImpl;
import org.apache.pulsar.common.api.proto.MessageIdData;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
Expand Down Expand Up @@ -413,7 +414,10 @@ public void testLastMessageIdForCompactedLedger() throws Exception {
.create();

Assert.assertTrue(reader.hasMessageAvailable());
Assert.assertEquals(msg, reader.readNext().getValue());
Message<String> received = reader.readNext();
Assert.assertEquals(msg, received.getValue());
MessageId messageId = ((ReaderImpl<String>) reader).getConsumer().getLastMessageId();
Assert.assertEquals(messageId, received.getMessageId());
Assert.assertFalse(reader.hasMessageAvailable());
}
}

0 comments on commit 102e3d2

Please sign in to comment.