Browse Source

YARN-10296. Make ContainerPBImpl#getId/setId synchronized. Contributed by Benjamin Teke

Szilard Nemeth 5 năm trước cách đây
mục cha
commit
a4835db95a

+ 3 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java

@@ -68,7 +68,7 @@ public class ContainerPBImpl extends Container {
     viaProto = true;
     viaProto = true;
   }
   }
   
   
-  public ContainerProto getProto() {
+  synchronized public ContainerProto getProto() {
   
   
     mergeLocalToProto();
     mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
     proto = viaProto ? proto : builder.build();
@@ -142,7 +142,7 @@ public class ContainerPBImpl extends Container {
   }
   }
 
 
   @Override
   @Override
-  public ContainerId getId() {
+  synchronized public ContainerId getId() {
     ContainerProtoOrBuilder p = viaProto ? proto : builder;
     ContainerProtoOrBuilder p = viaProto ? proto : builder;
     if (this.containerId != null) {
     if (this.containerId != null) {
       return this.containerId;
       return this.containerId;
@@ -176,7 +176,7 @@ public class ContainerPBImpl extends Container {
   }
   }
 
 
   @Override
   @Override
-  public void setId(ContainerId id) {
+  synchronized public void setId(ContainerId id) {
     maybeInitBuilder();
     maybeInitBuilder();
     if (id == null)
     if (id == null)
       builder.clearId();
       builder.clearId();