I'm considering reverting this patch for a few reasons.
First, the patch was not coded to handle Windows correctly. Changing it to use FileUtil#canRead would solve that.
However, the larger issue is that this might be backwards-incompatible. Prior to the patch, lack of access would return null. After the patch, lack of access throws an exception. Although this matches HDFS semantics, applications often have different expectations of the local file system. If an application was coded to check for null, but not handle AccessDeniedException, then there is a risk of breaking that application.
Cc Steve Loughran for a second opinion from the file system contract perspective. The current spec for listStatus does not explicitly require a pre-condition check that lack of access results in AccessDeniedException.
If we revert this, then something will have to be done about
YARN-4842, which included tests that depended on the new exception message. Cc Xuan Gong.
I won't revert immediately. I'll wait until next week so that others get time to consider and comment.