Skip to content

Add support for custom CloseableHttpClient for Proxy Support #441

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

Merged
merged 11 commits into from
Aug 26, 2021

Conversation

The-inside-man
Copy link
Contributor

Summary

  • Adding additional newDefaultInstance method to support custom CloseableHttpClient object
  • Allows for customs object to support Proxy Settings

Customer support

Test plan

  • FSC and TestCase added

Issues

  • "OASIS-7899"

@coveralls
Copy link

coveralls commented Aug 18, 2021

Pull Request Test Coverage Report for Build 1829

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 90.517%

Totals Coverage Status
Change from base Build 1828: 0.005%
Covered Lines: 4725
Relevant Lines: 5220

💛 - Coveralls

return newDefaultInstance(sdkKey, "");
}

public static Optimizely newDefaultInstance(String sdkKey, CloseableHttpClient httpClient) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so we need this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about removing this and add httpClient option to "newDefaultInstance(String sdkKey, String fallback, String datafileAccessToken, ClosableHttpClient httpClient)? Then no need for extra set method. Considering demands for customized httpclient, it may be reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

we can add default null in newDefaultInstance but that wouldn't be easy for the customer to initialize using your suggested method.

.withSdkKey(sdkKey);

HttpProjectConfigManager.Builder builder;
if (customHttpClient != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition should only set
.withOptimizelyHttpClient like we have for datafileAccessToken.
or without if condition you may set null using ternary operator that won't have any impact on OptimizelyHttpClient.

.withOptimizelyHttpClient( customHttpClient == null ? null : OHC instance

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

have few suggestions otherwise looks good to me.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Looks good. A couple of suggestions.

Comment on lines 54 to 59
public static void setCustomHttpClient(CloseableHttpClient httpClient) {
if (httpClient == null) {
logger.error("CloseableHttpClient must not be null. Please initialize object.");
}
customHttpClient = httpClient;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove this method (not consistent with the rest of set methods here for property settings) and feed into newInstance parameter.

return newDefaultInstance(sdkKey, "");
}

public static Optimizely newDefaultInstance(String sdkKey, CloseableHttpClient httpClient) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about removing this and add httpClient option to "newDefaultInstance(String sdkKey, String fallback, String datafileAccessToken, ClosableHttpClient httpClient)? Then no need for extra set method. Considering demands for customized httpclient, it may be reasonable.

@The-inside-man The-inside-man requested a review from jaeopt August 25, 2021 13:48
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Changes look good. A couple of more suggestions.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

One more cleanup

Comment on lines 277 to 282
NotificationCenter notificationCenter = new NotificationCenter();
HttpProjectConfigManager.Builder builder;
builder = HttpProjectConfigManager.builder()
.withDatafile(fallback)
.withNotificationCenter(notificationCenter)
.withSdkKey(sdkKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove these and use "newDefaultInstance(sdkKey, fallback, datafileAccessToken, null)"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahhh I see, makes sense. Just a minute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change, let me know if that is what you were thinking.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@The-inside-man The-inside-man merged commit 674cade into master Aug 26, 2021
@The-inside-man The-inside-man deleted the jbrown/proxy-builder branch August 26, 2021 18:57
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.

5 participants