You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/12 01:28:04 UTC
[GitHub] [pulsar] BewareMyPower commented on a change in pull request #9113: Fix NPE when MultiTopicsConsumerImpl receives null value messages
BewareMyPower commented on a change in pull request #9113:
URL: https://github.com/apache/pulsar/pull/9113#discussion_r555447864
##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java
##########
@@ -847,6 +847,15 @@ protected boolean hasPendingBatchReceive() {
return pendingBatchReceives != null && peekNextBatchReceive() != null;
}
+ protected void resetIncomingMessageSize() {
+ INCOMING_MESSAGES_SIZE_UPDATER.set(this, 0);
+ }
+
+ protected void updateIncomingMessageSize(final Message<?> message) {
+ INCOMING_MESSAGES_SIZE_UPDATER.addAndGet(this,
+ (message.getData() != null) ? message.getData().length : 0);
+ }
Review comment:
I think the previous implementation is wrong but there're no tests that expose the bug. The value only affects https://github.com/apache/pulsar/blob/d4c1677be93e5673672018f79da8a213514f01a3/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java#L673-L679
If it's negative, `INCOMING_MESSAGES_SIZE_UPDATER.get(this)` will be always negative and the comparison with `batchReceivePolicy.getMaxNumBytes()` is meaningless. I noticed the change was involved in #4621 , could you also take a look?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org