@@ -475,6 +475,7 @@ boolean doWaitForRestart() {
475475 private DataOutputStream blockStream ;
476476 private DataInputStream blockReplyStream ;
477477 private ResponseProcessor response = null ;
478+ private final Object nodesLock = new Object ();
478479 private volatile DatanodeInfo [] nodes = null ; // list of targets for current block
479480 private volatile StorageType [] storageTypes = null ;
480481 private volatile String [] storageIDs = null ;
@@ -613,7 +614,9 @@ private void setPipeline(LocatedBlock lb) {
613614
614615 private void setPipeline (DatanodeInfo [] nodes , StorageType [] storageTypes ,
615616 String [] storageIDs ) {
616- this .nodes = nodes ;
617+ synchronized (nodesLock ) {
618+ this .nodes = nodes ;
619+ }
617620 this .storageTypes = storageTypes ;
618621 this .storageIDs = storageIDs ;
619622 }
@@ -910,7 +913,10 @@ void waitForAckedSeqno(long seqno) throws IOException {
910913 try (TraceScope ignored = dfsClient .getTracer ().
911914 newScope ("waitForAckedSeqno" )) {
912915 LOG .debug ("{} waiting for ack for: {}" , this , seqno );
913- int dnodes = nodes != null ? nodes .length : 3 ;
916+ int dnodes ;
917+ synchronized (nodesLock ) {
918+ dnodes = nodes != null ? nodes .length : 3 ;
919+ }
914920 int writeTimeout = dfsClient .getDatanodeWriteTimeout (dnodes );
915921 long begin = Time .monotonicNow ();
916922 try {
0 commit comments