HDFS-7059. Avoid resolving path multiple times. Contributed by Jing Zhao.