MAPREDUCE-4987: only check isDirectory once per resource