Skip to content

Commit

Permalink
use simple for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
heesung-sn committed Nov 30, 2022
1 parent b236b86 commit 7be4cdd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import lombok.Getter;
import org.apache.pulsar.common.policies.data.NonPersistentPublisherStats;
Expand Down Expand Up @@ -155,8 +154,8 @@ public NonPersistentTopicStatsImpl add(NonPersistentTopicStats ts) {
Objects.requireNonNull(stats);
super.add(stats);
this.msgDropRate += stats.msgDropRate;
IntStream.range(0, stats.getNonPersistentPublishers().size()).forEach(index -> {
NonPersistentPublisherStats s = stats.getPublishers().get(index);
for (int index = 0; index < stats.getNonPersistentPublishers().size(); index++) {
NonPersistentPublisherStats s = stats.getNonPersistentPublishers().get(index);
if (s.isSupportsPartialProducer() && s.getProducerName() != null) {
((NonPersistentPublisherStatsImpl) this.nonPersistentPublishersMap
.computeIfAbsent(s.getProducerName(), key -> {
Expand All @@ -174,7 +173,7 @@ public NonPersistentTopicStatsImpl add(NonPersistentTopicStats ts) {
((NonPersistentPublisherStatsImpl) this.nonPersistentPublishers.get(index))
.add((NonPersistentPublisherStatsImpl) s);
}
});
}

if (this.getNonPersistentSubscriptions().size() != stats.getNonPersistentSubscriptions().size()) {
for (String subscription : stats.getNonPersistentSubscriptions().keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import lombok.AccessLevel;
import lombok.Data;
Expand Down Expand Up @@ -244,7 +243,7 @@ public TopicStatsImpl add(TopicStats ts) {
this.abortedTxnCount = stats.abortedTxnCount;
this.committedTxnCount = stats.committedTxnCount;

IntStream.range(0, stats.getPublishers().size()).forEach(index -> {
for (int index = 0; index < stats.getPublishers().size(); index++) {
PublisherStats s = stats.getPublishers().get(index);
if (s.isSupportsPartialProducer() && s.getProducerName() != null) {
this.publishersMap.computeIfAbsent(s.getProducerName(), key -> {
Expand All @@ -262,7 +261,7 @@ public TopicStatsImpl add(TopicStats ts) {
this.publishers.get(index)
.add((PublisherStatsImpl) s);
}
});
}

if (this.subscriptions.size() != stats.subscriptions.size()) {
for (String subscription : stats.subscriptions.keySet()) {
Expand Down

0 comments on commit 7be4cdd

Please sign in to comment.