HDFS-5615: prevent possible file handle leak