diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java index c1473dd268..4c733bfa24 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java @@ -1781,6 +1781,7 @@ boolean createBlockOutputStream(DatanodeInfo[] nodes, blockStream = out; result = true; // success errorState.resetInternalError(); + lastException.clear(); // remove all restarting nodes from failed nodes list failed.removeAll(restartingNodes); restartingNodes.clear(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientProtocolForPipelineRecovery.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientProtocolForPipelineRecovery.java index 3f8c7f7796..465a083841 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientProtocolForPipelineRecovery.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientProtocolForPipelineRecovery.java @@ -436,6 +436,8 @@ public Boolean get() { 0, out.getStreamer().getPipelineRecoveryCount()); out.write(1); out.close(); + // Ensure that subsequent closes are idempotent and do not throw errors + out.close(); } finally { if (cluster != null) { cluster.shutdown();