Skip to content

Files.isDirectory and friends are unsafe #1388

@novalis

Description

@novalis

Description of the problem / feature request:

Files.isDirectory, Files.isRegularFile and Files.isSymbolicLink ignore all IOExceptions (not just FileNotFound). This is almost never what you want; you want genuine IOExceptions like "the hard drive is on fire", or "the network is down, so NFS is not working" to get propagated.

These functions should not be used. ErrorProne should suggest Files.readAttributes instead. Automatic rewriting is hard because readAttributes throws IOException while the functions to be replaced do not.

Feature requests: what underlying problem are you trying to solve with this feature?

To replace unsafe functions with safe ones.

What version of Error Prone are you using?

3433532 (HEAD as of Oct 10, 2019)

Have you found anything relevant by searching the web?

I searched the bug tracker and mailing list for Files.isDirectory and found nothing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions