Shawyeok commented on a change in pull request #13742:
URL: https://github.com/apache/pulsar/pull/13742#discussion_r784147855
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
##########
@@ -356,14 +355,15 @@ public void enableCnxAutoRead() {
}
protected boolean hasLocalProducers() {
- AtomicBoolean foundLocal = new AtomicBoolean(false);
- producers.values().forEach(producer -> {
+ if (producers.isEmpty()) {
+ return false;
+ }
+ for (Producer producer : producers.values()) {
Review comment:
It's create a reusable ValuesView instance under
ConcurrentHashMap#values, not a copy I think.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
##########
@@ -356,14 +355,15 @@ public void enableCnxAutoRead() {
}
protected boolean hasLocalProducers() {
- AtomicBoolean foundLocal = new AtomicBoolean(false);
- producers.values().forEach(producer -> {
+ if (producers.isEmpty()) {
+ return false;
+ }
+ for (Producer producer : producers.values()) {
Review comment:
It's create a reusable `ValuesView` instance under
`ConcurrentHashMap#values`, not a copy I think.
--
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]