Skip to content

Fix retrying logic for HTTP responses with "Content-Type" other than "application/json"#2329

Merged
vam-google merged 1 commit intogoogleapis:masterfrom
vam-google:master
Aug 11, 2017
Merged

Fix retrying logic for HTTP responses with "Content-Type" other than "application/json"#2329
vam-google merged 1 commit intogoogleapis:masterfrom
vam-google:master

Conversation

@vam-google
Copy link
Copy Markdown
Contributor

This should fix #2098

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 10, 2017
@garrettjonesgoogle
Copy link
Copy Markdown
Contributor

How does it get to the exception instanceof GoogleJsonResponseException branch if Content-Type is not application/json?

@vam-google
Copy link
Copy Markdown
Contributor Author

This is caused by (I believe) some key design decisions in google-api-client. When you make a http request you may define it as a JSON request (the request class extends AbstractGoogleJsonClientRequest, and it is the case for StorageRequest). Unfortunately, the code is structured in a way that if your request is a JsonRequest, then it assumes that your error responses are also in Json.

Places, where things start going in a wrong direction are:

But regardless of these details, I believe the proposed fix is not only the simplest but at the same time the best we can have practically. In our clients retries are configured by error codes, not by content type. The current code, for some reason starts ignoring the error code if it cannot parse the message. Why? Error code should sill be treated as error code. It is ok to try to get more information from the message (it potentially allows to handle error better), bit if that does not succeed, we should fallback to checking just error code.

@garrettjonesgoogle
Copy link
Copy Markdown
Contributor

ok, LGTM

@vam-google vam-google merged commit 22e5423 into googleapis:master Aug 11, 2017
chingor13 pushed a commit that referenced this pull request Feb 20, 2026
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
meltsufin pushed a commit that referenced this pull request Apr 29, 2026
meltsufin pushed a commit that referenced this pull request May 1, 2026
meltsufin pushed a commit that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storage retries don't work as expected

3 participants