-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[java-client][okhttp-gson] fixes for interceptors in ApiClient.java #3502
Conversation
@@ -335,7 +335,7 @@ public void testInterceptorCleanupWithNewClient() { | |||
OkHttpClient oldClient = apiClient.getHttpClient(); | |||
assertEquals(1, oldClient.networkInterceptors().size()); | |||
|
|||
OkHttpClient newClient = new OkHttpClient(); | |||
OkHttpClient newClient = apiClient.getHttpClient().newBuilder().build(); |
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.
CircleCI reports that this change gets overridden when the samples are updated:
diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ApiClientTest.java
index 3675d8645a..6181e8afa2 100644
--- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ApiClientTest.java
+++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ApiClientTest.java
@@ -335,7 +335,7 @@ public class ApiClientTest {
OkHttpClient oldClient = apiClient.getHttpClient();
assertEquals(1, oldClient.networkInterceptors().size());
- OkHttpClient newClient = apiClient.getHttpClient().newBuilder().build();
+ OkHttpClient newClient = new OkHttpClient();
apiClient.setHttpClient(newClient);
assertEquals(1, apiClient.getHttpClient().networkInterceptors().size());
apiClient.setHttpClient(newClient);
This is because the source for this file is in the CI/samples.ci
folder. Can you update this file:
openapi-generator/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java
Line 338 in 6824bd8
OkHttpClient newClient = new OkHttpClient(); |
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.
@lostiniceland: Thank you a lot for this PR. It looks great.
Can you also change the mentioned file?
Updated as requested by review. I would argue though that the Tests I've fixed are not very usefull at all. They might have been with the old "logic" but now the tested method is a plain setter, except the check for equality, which could also be removed. |
@jmini I've added another commit which contains the mentioned invariant and removed the unnecessary tests |
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
@wing328 thanks for pointing that out. I've added my work-email to Github so it should match now. |
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.
LGTM. Thank you for the change.
@lostiniceland thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553 |
ApiClient for Okhttp3 must not copy the interceptors when setting the HttpClient.
fixes #3497