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 2022/04/14 05:38:34 UTC
[GitHub] [pulsar] lhotari commented on a diff in pull request #15132: [broker]Tidy up update subscribeRateLimiter
lhotari commented on code in PR #15132:
URL: https://github.com/apache/pulsar/pull/15132#discussion_r850094656
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -447,10 +442,12 @@ public void publishMessage(ByteBuf headersAndPayload, PublishContext publishCont
public void updateSubscribeRateLimiter() {
SubscribeRate subscribeRate = this.getSubscribeRate();
- if (isSubscribeRateEnabled(subscribeRate)) {
- subscribeRateLimiter = Optional.of(subscribeRateLimiter.orElse(new SubscribeRateLimiter(this)));
- } else {
- subscribeRateLimiter = Optional.empty();
+ synchronized (subscribeRateLimiter) {
Review Comment:
`synchronized(subscribeRateLimiter)` seems wrong. I can now see that this came from the original code. This should be fixed.
One possible fix is to make the `subscribeRateLimiter` field a `volatile` field.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org