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/07/23 02:29:58 UTC

[GitHub] [pulsar] codelipenghui commented on a diff in pull request #16742: [fix][flaky-test] BrokerInterceptorTest.testProducerCreation

codelipenghui commented on code in PR #16742:
URL: https://github.com/apache/pulsar/pull/16742#discussion_r928067228


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/CounterBrokerInterceptor.java:
##########
@@ -48,18 +48,18 @@
 @Slf4j
 public class CounterBrokerInterceptor implements BrokerInterceptor {
 
-    int beforeSendCount = 0;
-    int count = 0;
-    int connectionCreationCount = 0;
-    int producerCount = 0;
-    int consumerCount = 0;
-    int messageCount = 0;
-    int messageDispatchCount = 0;
-    int messageAckCount = 0;
-    int handleAckCount = 0;
-    int txnCount = 0;
-    int committedTxnCount = 0;
-    int abortedTxnCount = 0;
+    private volatile int beforeSendCount = 0;
+    private volatile int count = 0;
+    private volatile int connectionCreationCount = 0;
+    private volatile int producerCount = 0;
+    private volatile int consumerCount = 0;
+    private volatile int messageCount = 0;
+    private volatile int messageDispatchCount = 0;
+    private volatile int messageAckCount = 0;
+    private volatile int handleAckCount = 0;
+    private volatile int txnCount = 0;
+    private volatile int committedTxnCount = 0;
+    private volatile int abortedTxnCount = 0;

Review Comment:
   Looks like it's better to change AtomicInteger here since we can have multiple threads access the BrokerInterceptor.



-- 
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