-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conversation
Pull Request Test Coverage Report for Build 1829
💛 - Coveralls |
return newDefaultInstance(sdkKey, ""); | ||
} | ||
|
||
public static Optimizely newDefaultInstance(String sdkKey, CloseableHttpClient httpClient) { |
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.
I don't think so we need this method.
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.
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.
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.
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) { |
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.
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
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.
have few suggestions otherwise looks good to me.
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.
Looks good. A couple of suggestions.
public static void setCustomHttpClient(CloseableHttpClient httpClient) { | ||
if (httpClient == null) { | ||
logger.error("CloseableHttpClient must not be null. Please initialize object."); | ||
} | ||
customHttpClient = httpClient; | ||
} |
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.
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) { |
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.
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.
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.
Changes look good. A couple of more suggestions.
core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java
Outdated
Show resolved
Hide resolved
core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java
Show resolved
Hide resolved
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.
One more cleanup
NotificationCenter notificationCenter = new NotificationCenter(); | ||
HttpProjectConfigManager.Builder builder; | ||
builder = HttpProjectConfigManager.builder() | ||
.withDatafile(fallback) | ||
.withNotificationCenter(notificationCenter) | ||
.withSdkKey(sdkKey); |
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.
Let's remove these and use "newDefaultInstance(sdkKey, fallback, datafileAccessToken, null)"
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.
ahhh I see, makes sense. Just a minute.
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.
Made the change, let me know if that is what you were thinking.
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
Summary
Customer support
Test plan
Issues