srkukarni commented on a change in pull request #7010:
URL: https://github.com/apache/pulsar/pull/7010#discussion_r428968508



##########
File path: 
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
##########
@@ -546,13 +547,17 @@ synchronized public void close() {
         }
     }
 
-    public InstanceCommunication.MetricsData getAndResetMetrics() {
+    // This method is synchronized because it is using the stats variable
+    synchronized public InstanceCommunication.MetricsData getAndResetMetrics() 
{
         InstanceCommunication.MetricsData metricsData = getMetrics();
-        stats.reset();
+        if (stats != null) {
+            stats.reset();
+        }
         return metricsData;
     }
 
-    public InstanceCommunication.MetricsData getMetrics() {
+    // This method is synchronized because it is using the stats and 
javaInstance variables
+    synchronized public InstanceCommunication.MetricsData getMetrics() {

Review comment:
       Changed it




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to