fapaul commented on a change in pull request #16971:
URL: https://github.com/apache/flink/pull/16971#discussion_r695822749



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/testutils/InMemoryReporter.java
##########
@@ -159,17 +168,51 @@ void applyRemovals() {
 
     @Override
     public void notifyOfAddedMetric(Metric metric, String metricName, 
MetricGroup group) {
-        MetricGroup metricGroup = unwrap(group);
-        LOG.debug("Registered {} @ {}", metricName, metricGroup);
-        synchronized (this) {
-            metrics.computeIfAbsent(metricGroup, dummy -> new 
HashMap<>()).put(metricName, metric);
+        if (captureMode != CaptureMode.NONE) {
+            MetricGroup metricGroup = unwrap(group);
+            LOG.debug("Registered {} @ {}", metricName, metricGroup);
+            synchronized (this) {
+                metrics.computeIfAbsent(metricGroup, dummy -> new HashMap<>())

Review comment:
       I think one easy thing is probably to `synchronize` the two methods 
`notifyOfRemovedMetric` `notifyOfAddedMetric` if performance is no concern here 
and will add at least some clarity.




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


Reply via email to