Skip to content

HttpStorageRpc connection leakage #3379

@steingrd

Description

@steingrd

The class com.google.cloud.storage.spi.v1.HttpStorageRpc in google-cloud-storage provides two methods named open() that return the location header from the HTTP response. Both methods fail to properly close the underlying HTTP response returned from com.google.api.client.http.HttpRequest.

The javadoc on com.google.api.client.http.HttpRequest.execute() states:

Callers should call HttpResponse.disconnect when the 
returned HTTP response object is no longer needed.  
However, HttpResponse.disconnect does not have to be 
called if the response stream is properly closed

However the usage in HttpStorageRpc.open() extracts the location header and returns it directly without closing the http response:

HttpResponse response = httpRequest.execute();
if (response.getStatusCode() != 200) {
   throw buildStorageException(response.getStatusCode(), response.getStatusMessage());
}
return response.getHeaders().getLocation();

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the googleapis/java-storage API.

    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