-
Notifications
You must be signed in to change notification settings - Fork 938
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
HTTPCLIENT-2343 - Enhance HttpClientContext
user token management for improved compatibility
#584
Conversation
…or improved compatibility. Refined the `getUserToken()` method in `HttpClientContext` to prioritize retrieving the internal `userToken` field before falling back to context attributes. This adjustment ensures backward compatibility while encouraging the recommended approach for managing user tokens, laying the groundwork for a smoother transition as legacy methods are phased out.
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.
@arturobernalg I am sorry but this needs to be done differently. Context attributes are mostly "written seldom / read often". Adding a map lookup to #getUserToken
is wrong and adds unnecessary overhead. Override #setAttribute
instead and update context instance variables along with the map.
Hi @ok2c |
@arturobernalg So what? |
@arturobernalg If both test cases pass, it would be good enough.
|
…ute set through context attributes and its retrieval via getUserToken(), ensuring that the behavior is consistent across different ways of setting the user token.
@ok2c both test pass correctly. |
@arturobernalg Right, but you are still doing a map lookup in |
@ok2c The test failed, confirming that the current approach doesn't resolve the issue effectively. |
@ok2c Given the test results It might be best to consider closing the ticket as "WONTFIX" since the optimization goals aren't met with the current implementation. |
@arturobernalg My idea was to move the compensatory code to |
This PR refines the way user tokens are managed within
HttpClientContext
. Specifically, thegetUserToken()
method has been enhanced to first check the internaluserToken
field, and only fall back to context attributes for backward compatibility. A warning log has been added to notify developers when this fallback occurs, strongly encouraging the preferred usage ofsetUserToken(Object)
for setting user tokens.