Skip to content

FSBlobContainer leniently truncates #15579

@rmuir

Description

@rmuir

The two write methods are defined like this:

    public void writeBlob(String blobName, InputStream inputStream, long blobSize) throws IOException {
        final Path file = path.resolve(blobName);
        try (OutputStream outputStream = Files.newOutputStream(file)) {
            ...

Passing nothing to Files.newOutputStream will truncate the output file if its already there:

If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present. In other words, it opens the file for writing, creating the file if it doesn't exist, or initially truncating an existing regular-file to a size of 0 if it exists. 

Can we please pass StandardOpenOptions.CREATE_NEW so that silent data truncation never happens?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions