zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #584: ZOOKEEPER-3102: Potential race condition when c...
Date Fri, 27 Jul 2018 11:58:38 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/584#discussion_r205749086
  
    --- Diff: src/java/main/org/apache/zookeeper/server/DataTree.java ---
    @@ -478,7 +478,10 @@ public void createNode(final String path, byte data[], List<ACL>
acl,
                     HashSet<String> list = ephemerals.get(ephemeralOwner);
                     if (list == null) {
                         list = new HashSet<String>();
    -                    ephemerals.put(ephemeralOwner, list);
    +                    HashSet<String> _list;
    --- End diff --
    
    You can use `computeIfAbsent()` like this:
    ```java
    HashSet<String> list = ephemerals.computeIfAbsent(ephemeralOwner, k -> new HashSet<String>());
    ```


---

Mime
View raw message