Skip to content

ContentServiceAsync.retrieve does not return the contents that you retrieved, and usage of @MustBeClosed is wrong #489

@bbeaudreault

Description

@bbeaudreault

ContentServiceAsync.retrieve() just returns a CompletableFuture<Void>. So there's no way to actually access what was retrieved by the API call.

The only way to do it is with ContentServiceAsync.withRawResponse().retrieve(). This returns a CompletableFuture<HttpResponse> from which you can access the body as an InputStream. This works, but has its own problem. This method is annotated with @MustBeClosed, which does not apply to CompletableFuture. The contract of @MustBeClosed is that the actual return value has to be closed, but you can't close a CompletableFuture. What you want here is to ensure that the HttpResponse is closed, but that's not how the check works.

This CompletableFuture problem is actually not limited to ContentServiceAsync. I see the same problem in FileServiceAsync, and it may be in others as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions