Skip to content

Files.touch causes unnecessary disk contention #3612

Open
@li-a

Description

When calling Files.touch(foo) on a file that already exists, Guava will call java.io.File#createNewFile() and assume the file already exists if the creation operation fails. But because Java guarantees the existence check and creation are atomic, the existence check lives inside a call to java.io.FileSystem#createFileExclusively, introducing concurrency penalties that might not be needed.

Instead, Guava should skip file.createNewFile() when file.exists() returns true.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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