-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unzip/Deflate content on error status for Default Client #2184
Conversation
WalkthroughThe changes primarily focus on improving the handling of gzip and deflate encoded responses in the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 3
Files selected for processing (5)
- core/src/main/java/feign/Client.java (1 hunks)
- core/src/test/java/feign/client/AbstractClientTest.java (4 hunks)
- googlehttpclient/src/test/java/feign/googlehttpclient/GoogleHttpClientTest.java (1 hunks)
- jaxrs2/src/test/java/feign/jaxrs2/JAXRSClientTest.java (1 hunks)
- okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java (1 hunks)
Files skipped from review due to trivial changes (2)
- core/src/main/java/feign/Client.java
- googlehttpclient/src/test/java/feign/googlehttpclient/GoogleHttpClientTest.java
Additional comments (Suppressed): 5
core/src/test/java/feign/client/AbstractClientTest.java (4)
20-21: The import statement for
org.junit.Assert.fail
has been added. Ensure that this new import does not conflict with any existing methods in the class.35-35: The import statement for
java.nio.ByteBuffer
has been added. Make sure this new import is used within the code and it doesn't conflict with any existing methods in the class.415-439: A new test method
canSupportGzipOnError()
has been added. This test checks if the client can handle gzip compressed error responses correctly. The test enqueues a mock response with a 400 status code and gzip encoding, then asserts that the response body is correctly unzipped.459-482: A new test method
canSupportDeflateOnError()
has been added. This test checks if the client can handle deflate compressed error responses correctly. The test enqueues a mock response with a 400 status code and deflate encoding, then asserts that the response body is correctly unzipped.jaxrs2/src/test/java/feign/jaxrs2/JAXRSClientTest.java (1)
- 167-168: The new test methods
canSupportGzipOnError
andcanSupportDeflateOnError
have been added to verify the handling of gzip and deflate encoded error responses. However, these tests are set to always fail withassumeFalse()
, indicating that the JaxRS client does not support gzip or deflate compression. If this is the expected behavior, then the changes are fine. Otherwise, the logic in these tests may need to be revised.
This MR is about processing gzip or deflate content when error status is >= 400 on default http client. Hope it would help solving this issue from 2021 :) |
Plenty more from well dates waiting for community fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (1)
- okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java (1 hunks)
Files skipped from review due to trivial changes (1)
- okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java
And this is probably not the most awaited one. Hope I will help for others in the future. |
40773b8
to
8a8c490
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 4
Files selected for processing (5)
- core/src/main/java/feign/Client.java (1 hunks)
- core/src/test/java/feign/client/AbstractClientTest.java (4 hunks)
- googlehttpclient/src/test/java/feign/googlehttpclient/GoogleHttpClientTest.java (1 hunks)
- jaxrs2/src/test/java/feign/jaxrs2/JAXRSClientTest.java (1 hunks)
- okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java (1 hunks)
Files skipped from review due to trivial changes (1)
- googlehttpclient/src/test/java/feign/googlehttpclient/GoogleHttpClientTest.java
Additional comments (Suppressed): 7
core/src/test/java/feign/client/AbstractClientTest.java (4)
20-20: The import statement for
fail
fromorg.junit.Assert
has been added. Ensure that this import is necessary and used in the updated code.35-35: The import statement for
ByteBuffer
fromjava.nio
has been added. Ensure that this import is necessary and used in the updated code.415-439: The new test method
canSupportGzipOnError
has been added. This method tests the behavior when receiving a gzip-encoded error response. The test checks that the response is correctly unzipped and matches the expected data. The test setup and assertions look correct.459-482: The new test method
canSupportDeflateOnError
has been added. This method tests the behavior when receiving a deflate-encoded error response. The test checks that the response is correctly unzipped and matches the expected data. The test setup and assertions look correct.jaxrs2/src/test/java/feign/jaxrs2/JAXRSClientTest.java (3)
152-158: The new methods
canSupportGzipOnError
andcanSupportDeflateOnError
have been added to test the behavior when receiving a zipped response with a 400 status code. However, they are currently set to always assume false, indicating that the JAX-RS client does not support gzip or deflate compression. If this is the intended behavior, then the changes are fine. If not, the logic within these methods should be updated to accurately reflect the capabilities of the JAX-RS client.165-171: The method
canSupportDeflateOnError
has been added to test the behavior when receiving a deflated response with a 400 status code. However, it is currently set to always assume false, indicating that the JAX-RS client does not support deflate compression. If this is the intended behavior, then the changes are fine. If not, the logic within this method should be updated to accurately reflect the capabilities of the JAX-RS client.172-172: The method
canExceptCaseInsensitiveHeader
is still checking for gzip compression support, which doesn't align with its name. This was previously flagged in the comment chain and the author suggested addressing it in a separate PR. However, it's important to ensure that our tests accurately reflect what they're supposed to be testing. In this case, thecanExceptCaseInsensitiveHeader
method is currently checking for gzip compression support, which doesn't align with its name or intended purpose. I recommend correcting it now to prevent potential confusion or errors in future testing.@Override public void canExceptCaseInsensitiveHeader() throws Exception { - assumeFalse("JaxRS client do not support gzip compression", false); + // Corrected test logic should go here + // For example: + assumeTrue("JaxRS client should support case-insensitive headers", true); }
rebased this last changes on master branch. |
* Unzip/Deflate content on error status for Default Client * Fix assert message --------- Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
* Unzip/Deflate content on error status for Default Client * Fix assert message --------- Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
Summary by CodeRabbit