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 76e86adf87f..3568a70f349 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 @@ -400,7 +400,7 @@ public class ProtoUtils { /* * 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 6ebed6e0576..7d334bfd965 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 @@ -71,14 +71,14 @@ public class ResourcePBImpl extends Resource { 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); } @@ -127,7 +127,7 @@ public class ResourcePBImpl extends Resource { resources[VCORES_INDEX].setValue(vCores); } - private void initResources() { + synchronized private void initResources() { if (this.resources != null) { return; }