Github user lvfangmin commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/102#discussion_r87264725 --- Diff: src/java/main/org/apache/zookeeper/server/DataTree.java --- @@ -1293,13 +1293,12 @@ public synchronized WatchesSummary getWatchesSummary() { * @param pwriter the output to write to */ public void dumpEphemerals(PrintWriter pwriter) { - Set<Long> keys = ephemerals.keySet(); pwriter.println("Sessions with Ephemerals (" - + keys.size() + "):"); - for (long k : keys) { - pwriter.print("0x" + Long.toHexString(k)); + + ephemerals.keySet().size() + "):"); + for (Entry<Long, HashSet<String>> entry : ephemerals.entrySet()) { + pwriter.print("0x" + Long.toHexString(entry.getKey())); pwriter.println(":"); - HashSet<String> tmp = ephemerals.get(k); + HashSet<String> tmp = entry.getValue(); --- End diff -- Usually, prefer to use the interface if we only use the methods defined in the interface, which makes it flexible (or less change needed) in case we want to use another Set implementation. There is a best practice defined in Effective Java 2nd Edition, Item 52: Refer to objects by their interfaces: If appropriate interface types exist, then parameters, return values, and fields should all be declared using interface types. If you get into the habit of using interface types, your program will be much more flexible. It is entirely appropriate to refer to an object by a class if no appropriate interface exists.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---