HDFS-5715 and HDFS-5726. Merge change r1556353 and r1556433 from trunk.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1568217 13f79535-47bb-0310-9956-ffa450edef68