fix concurrency problem

This commit is contained in:
fjy 2013-07-08 10:40:13 -07:00
parent 5ac2d1db0b
commit 83b96ee507
1 changed files with 1 additions and 2 deletions

View File

@ -227,10 +227,9 @@ public class Announcer
boolean created = false;
synchronized (toAnnounce) {
if (started) {
byte[] oldBytes = subPaths.get(pathAndNode.getNode());
byte[] oldBytes = subPaths.putIfAbsent(pathAndNode.getNode(), bytes);
if (oldBytes == null) {
subPaths.put(pathAndNode.getNode(), bytes);
created = true;
} else if (!Arrays.equals(oldBytes, bytes)) {
throw new IAE("Cannot reannounce different values under the same path");