diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java index 3f360d764c..64b49c86b4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java @@ -412,7 +412,7 @@ public static ContainerUpdateType convertFromProtoFormat( /* * Resource */ - public static synchronized ResourceProto convertToProtoFormat(Resource r) { + public static ResourceProto convertToProtoFormat(Resource r) { return ResourcePBImpl.getProto(r); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java index 36fc959cbb..ed9f3dbb8c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java @@ -75,14 +75,14 @@ public ResourcePBImpl(ResourceProto proto) { initResources(); } - public ResourceProto getProto() { + synchronized public ResourceProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } - private void maybeInitBuilder() { + synchronized private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ResourceProto.newBuilder(proto); } @@ -131,7 +131,7 @@ public void setVirtualCores(int vCores) { resources[VCORES_INDEX].setValue(vCores); } - private void initResources() { + synchronized private void initResources() { if (this.resources != null) { return; }