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

fix #4708 refining what is possible via the requestconfig #4837

Merged
merged 4 commits into from
Feb 22, 2023

Conversation

shawkins
Copy link
Contributor

@shawkins shawkins commented Feb 6, 2023

Description

Fixes #4708

There are several goals here. The first is to ensure that only config values that can be changed without creating a new httpclient can be set on the RequestConfig - that means connectionTimeout cannot be there. The next is that allowing for authentication related overrides complicates the logic and any documentation we'd want to create around the refresh interceptors, so it's not a good idea to allow that to be set on a per request basis. It also seems unnecessary to override the oauthtokenprovider as the user already has control over how the token should be provided.

The next goal was to minimize our changes to the Config (the full application of those changes is often unclear and/or may require a new httpclient) - after this the config is nearly immutable and not copied - we're no longer creating copies to override the RequestConfig, nor for the namespace handling. This means that places in the client which were referencing the config to get RequestConfig values were changed to reference a contextual RequestConfig. The only logic that is still modifying the config is the token refresh - and this will likely get refined with #4802.

To clean up how Interceptors reference the config, there is not an explicit parameter that finds tags associated with the request - this is not actually on the HttpRequest as we create those in other places and it's simpler not to have to find the tags that were applicable at that point and only deal with this concept as part of the Interceptors. Due to this and the change to using the standard logic we can pass the full request, not just the headers into the interceptor methods. After #4825 we'll be able to also add a generalized after method for regular requests - this should give us the full set of methods needed to introduce generalized logging interception.

This did not attempt to introduce new entry logic for override the requestconfig - it is still through the withRequestConfig method. If we do provide other DSL entry points for such modifications they should use the same internal method for constructing a new Client / derived HttpClient that will have the appropriate overrides.

This does have conflicts with #4825 - but they will be straight-forward to resolve after one of them is committed.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@manusa
Copy link
Member

manusa commented Feb 20, 2023

Tried to quickly merge master but it needs more work 😓

@shawkins
Copy link
Contributor Author

Tried to quickly merge master but it needs more work

That's likely - there have been some overlapping changes of late. After this goes in and #4877, then the extra fields will be removed as well.

@manusa
Copy link
Member

manusa commented Feb 20, 2023

Shall we merge #4877 first? (seems cleaner at the moment)

@shawkins
Copy link
Contributor Author

Shall we merge #4877 first? (seems cleaner at the moment)

That's good with me, I'll clean this one up after that.

@shawkins
Copy link
Contributor Author

@manusa should be good now

@sonarcloud
Copy link

sonarcloud bot commented Feb 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

57.8% 57.8% Coverage
2.1% 2.1% Duplication

}
public interface RequestTags {

<T> T getTag(Class<T> type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we should document what a Request tag is and what can it be used for

@manusa manusa added this to the 6.5.0 milestone Feb 22, 2023
@manusa manusa merged commit b83927f into fabric8io:master Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refine what is possible via withRequestConfig
2 participants