[java] Improving exception when server returns 504 (WIP) #9354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here I'm adding one extra condition to
W3CHttpResponseCodec#decode
in order to specifically handle 504 Gateway Time-out server errors.This fix is very similar to the fix that was applied in 6a9c546 (see #7792).
Motivation and Context
While running a test on a Selenium Grid (v3.141.59), I got the following pretty unfriendly exception upon a
WebElement#click
call:Only by debugging the test and stepping through the calls, I was able to find that the server was actually returning a plain text response:
It shouldn't be required from the end user to do this.
Types of changes
Checklist
PS: I was wondering if it makes sense to extend this special handling logic to any 4XX/5XX errors, instead of only to 405 and 504.
I mean, I would expect the server to return a Json only when the HTTP status is 200.
I did some research and I found that
AbstractHttpResponseCodec
(the superclass ofW3CHttpResponseCodec
) is already doing what I was thinking:selenium/java/client/src/org/openqa/selenium/remote/codec/AbstractHttpResponseCodec.java
Line 105 in fcfbc6b
On the other hand, I also see that in W3CHttpResponseCodec there's a line which expects to get a JSON together with a 500 error 😕
selenium/java/client/src/org/openqa/selenium/remote/codec/w3c/W3CHttpResponseCodec.java
Line 117 in fcfbc6b
@shs96c can you maybe spread some light? Tagging you as the author of
W3CHttpResponseCodec
Thanks!