poorbarcode commented on code in PR #23943:
URL: https://github.com/apache/pulsar/pull/23943#discussion_r1947408252
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -2831,27 +2831,18 @@ private Optional<EncryptionContext>
createEncryptionContext(MessageMetadata msgM
private int removeExpiredMessagesFromQueue(Set<MessageId> messageIds) {
int messagesFromQueue = 0;
- Message<T> peek = incomingMessages.peek();
- if (peek != null) {
- MessageId messageId =
NegativeAcksTracker.discardBatchAndPartitionIndex(peek.getMessageId());
- if (!messageIds.contains(messageId)) {
- // first message is not expired, then no message is expired in
queue.
- return 0;
- }
-
- // try not to remove elements that are added while we remove
- Message<T> message = incomingMessages.poll();
- while (message != null) {
- decreaseIncomingMessageSize(message);
- messagesFromQueue++;
- MessageId id =
NegativeAcksTracker.discardBatchAndPartitionIndex(message.getMessageId());
- if (!messageIds.contains(id)) {
- messageIds.add(id);
- break;
- }
- message.release();
- message = incomingMessages.poll();
+ Message<T> message;
+ while (true) {
+ message = incomingMessages.pollIf(msg -> {
+ MessageId idPoled =
NegativeAcksTracker.discardBatchAndPartitionIndex(msg.getMessageId());
Review Comment:
Fixed
--
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]