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



##########
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<>())
+                        .put(metricName, metric);
+            }
         }
     }
 
     @Override
     public void notifyOfRemovedMetric(Metric metric, String metricName, 
MetricGroup group) {
-        synchronized (this) {
-            removedGroups.add(unwrap(group));
+        if (captureMode != CaptureMode.NONE) {

Review comment:
       I'm not particularly happy with all the `if-else` but I haven't found a 
way to express it without severely overengineering. @tillrohrmann any ideas?




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