flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StefanRRichter <...@git.apache.org>
Subject [GitHub] flink pull request #5959: [FLINK-9258][metrics] Thread-safe initialization o...
Date Wed, 23 May 2018 08:37:49 GMT
Github user StefanRRichter commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5959#discussion_r190165058
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/ComponentMetricGroup.java
---
    @@ -57,11 +57,12 @@ public ComponentMetricGroup(MetricRegistry registry, String[] scope,
P parent) {
     		if (variables == null) { // avoid synchronization for common case
     			synchronized (this) {
     				if (variables == null) {
    -					variables = new HashMap<>();
    -					putVariables(variables);
    +					Map<String, String> tmpVariables = new HashMap<>();
    +					putVariables(tmpVariables);
     					if (parent != null) { // not true for Job-/TaskManagerMetricGroup
    -						variables.putAll(parent.getAllVariables());
    +						tmpVariables.putAll(parent.getAllVariables());
     					}
    +					variables = tmpVariables;
    --- End diff --
    
    This looks potentially still broken to me because it does double-checked locking, which
is a defective anti-pattern.


---

Mime
View raw message