Skip to content
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

[BUG] Jersey2 Client setting debug doesn't rebuild the httpClient #8185

Closed
6 tasks
nmuesch opened this issue Dec 14, 2020 · 3 comments
Closed
6 tasks

[BUG] Jersey2 Client setting debug doesn't rebuild the httpClient #8185

nmuesch opened this issue Dec 14, 2020 · 3 comments

Comments

@nmuesch
Copy link
Contributor

nmuesch commented Dec 14, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Setting the debug option in the ApiClient doesn't fully enable debug logging.
There is a comment here about rebuilding the client when setDebugging is enabled - https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache#L603. However this continues to use the previously built clientConfig - https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache#L1239 that was initialized from the constructor.

The result is not seeing the request/response being logged after calling setDebugging to True. One possible solution would be to not have the null check in the above link and always rebuild the http client, but that may not be desired.

openapi-generator version

Latest master commit

OpenAPI declaration file content or url
Generation Details

No specific spec needed, this is generated currently in the existing petStore jersey2 example.

Steps to reproduce
Related issues/PRs

I couldn't find another similar reported issue.

Suggest a fix

More details in the Description section.

@davidmoten
Copy link

I've noticed this too. No logging at all despite calling ApiClient.setDebugging(true) with openapi-generator-maven-plugin 5.0.0-beta3.

@nmuesch
Copy link
Contributor Author

nmuesch commented Dec 18, 2020

I believe the issue is around this nil check - https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache#L1239-L1241, removing that check lets the httpclient fully rebuild with the debug flag enabled, and sets up the logging for the request/response.
Though I'm not sure if it will cause any issues removing this cache. From the other parts of the template that call this, it looks like the intent is to trigger a refresh.

@nmuesch
Copy link
Contributor Author

nmuesch commented Mar 27, 2021

Closing, as this should be solved by #8756

@nmuesch nmuesch closed this as completed Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants