codelipenghui commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1059248729
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/NonPersistentTopicStatsImpl.java:
##########
@@ -165,20 +166,15 @@ public NonPersistentTopicStatsImpl
add(NonPersistentTopicStats ts) {
return newStats;
})).add((NonPersistentPublisherStatsImpl) s);
} else {
- if (this.nonPersistentPublishers.size() !=
stats.getNonPersistentPublishers().size()) {
- for (int i = 0; i <
stats.getNonPersistentPublishers().size(); i++) {
- NonPersistentPublisherStatsImpl newStats = new
NonPersistentPublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
-
this.nonPersistentPublishers.add(newStats.add((NonPersistentPublisherStatsImpl)
s));
- }
- } else {
- for (int i = 0; i <
stats.getNonPersistentPublishers().size(); i++) {
- ((NonPersistentPublisherStatsImpl)
this.nonPersistentPublishers.get(i))
- .add((NonPersistentPublisherStatsImpl) s);
- }
+ if (index == this.nonPersistentPublishers.size()) {
+ NonPersistentPublisherStatsImpl newStats = new
NonPersistentPublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.nonPersistentPublishers.add(newStats);
Review Comment:
It's better to add some description for this `if` branch. Like why we need
to use a newStats if `index == this.nonPersistentPublishers.size()`. And what
does `index == this.nonPersistentPublishers.size()` exactly means. Frankly,
it's not easy to understand. I think if we have some description, it will help
the readers.
--
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]