HDFS-5612: simplify by consolidating some conditional checks.