Github user MichaelScofield commented on the issue: https://github.com/apache/zookeeper/pull/584 @anmolnar Sorry for the late response. I think what @lvfangmin wants to put here, is that `createNode()` is called in single thread, so the race condition does not exist. **IF** there were multi-threaded call, a lot of codes would have broken, including the `killSession()`. However, the original code might have synchronized on a wrong `list`: ``` HashSet<String> list = ephemerals.get(ephemeralOwner); if (list == null) { list = new HashSet<String>(); ephemerals.put(ephemeralOwner, list); } // the "list" here is assumed to be contented, if it's created or altered elsewhere // (not bounded by the single-threaded guarantee), we might have synchronized // on a wrong object (that we just created). synchronized (list) { list.add(path); } ``` I'm just trying to make the codes look more robust.
---