diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index ecde27339b3..176d730efc8 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -1217,6 +1217,9 @@ Release 0.23.0 - Unreleased MAPREDUCE-2908. Fix all findbugs warnings. (vinodkv via acmurthy) + MAPREDUCE-2947. Fixed race condition in AuxiliaryServices. (vinodkv via + acmurthy) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java index 4fbdf97c7c9..a01b11bac18 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java @@ -48,20 +48,20 @@ public class StartContainerResponsePBImpl extends ProtoBase getAllServiceResponse() { + public synchronized Map getAllServiceResponse() { initServiceResponse(); return this.serviceResponse; } @Override - public ByteBuffer getServiceResponse(String key) { + public synchronized ByteBuffer getServiceResponse(String key) { initServiceResponse(); return this.serviceResponse.get(key); } - private void initServiceResponse() { + private synchronized void initServiceResponse() { if (this.serviceResponse != null) { return; } @@ -103,14 +103,14 @@ public class StartContainerResponsePBImpl extends ProtoBase serviceResponse) { + public synchronized void addAllServiceResponse(final Map serviceResponse) { if (serviceResponse == null) return; initServiceResponse(); this.serviceResponse.putAll(serviceResponse); } - private void addServiceResponseToProto() { + private synchronized void addServiceResponseToProto() { maybeInitBuilder(); builder.clearServiceResponse(); if (serviceResponse == null) @@ -118,24 +118,24 @@ public class StartContainerResponsePBImpl extends ProtoBase iterable = new Iterable() { @Override - public Iterator iterator() { + public synchronized Iterator iterator() { return new Iterator() { Iterator keyIter = serviceResponse.keySet().iterator(); @Override - public void remove() { + public synchronized void remove() { throw new UnsupportedOperationException(); } @Override - public StringBytesMapProto next() { + public synchronized StringBytesMapProto next() { String key = keyIter.next(); return StringBytesMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(serviceResponse.get(key))).build(); } @Override - public boolean hasNext() { + public synchronized boolean hasNext() { return keyIter.hasNext(); } }; @@ -144,17 +144,17 @@ public class StartContainerResponsePBImpl extends ProtoBase getMeta() { - return Collections.unmodifiableMap(serviceMeta); + Map metaClone = new HashMap( + serviceMeta.size()); + synchronized (serviceMeta) { + for (Entry entry : serviceMeta.entrySet()) { + metaClone.put(entry.getKey(), entry.getValue().duplicate()); + } + } + return metaClone; } @Override