Skip to content

DownloadsBackend inconsistently closes streams #471

@omus

Description

@omus

The following test case is from #470:

@testset "issue 466" begin
    file_name = "hang.txt"

    try
        S3.put_object("anewbucket", file_name)

        # Note: Using `eof` for these tests can hang when using an unclosed `Base.BufferStream`

        stream = S3.get_object("anewbucket", file_name, Dict("return_stream" => true))
        if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend
            @test !isopen(stream)
        else
            @test isopen(stream)
        end

        stream = Base.BufferStream()
        S3.get_object("anewbucket", file_name, Dict("response_stream" => stream))
        if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend
            @test !isopen(stream)
        else
            @test_broken isopen(stream)
        end

        stream = Base.BufferStream()
        S3.get_object(
            "anewbucket",
            file_name,
            Dict("response_stream" => stream, "return_stream" => true),
        )
        if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend
            @test !isopen(stream)
        else
            @test isopen(stream)
        end
    finally
        S3.delete_object("anewbucket", file_name)
    end
end

Note how when using a non-IOBuffer and not using the "return_stream" parameter that the I/O stream is closed but in all other cases it leaves the stream open. This inconsistency should not be present.

Additionally, most likely the behaviour of the HTTPBackend and the DownloadsBackend should made to be consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions