@@ -147,19 +147,19 @@ public void initWithNiwsConfig(IClientConfig clientConfig) {
147147 super .initWithNiwsConfig (clientConfig );
148148 this .ncc = clientConfig ;
149149 this .restClientName = ncc .getClientName ();
150- this .isSecure = getBooleanFromConfig ( ncc , CommonClientConfigKey .IsSecure , this .isSecure );
151- this .isHostnameValidationRequired = getBooleanFromConfig ( ncc , CommonClientConfigKey .IsHostnameValidationRequired , this .isHostnameValidationRequired );
152- this .isClientAuthRequired = getBooleanFromConfig ( ncc , CommonClientConfigKey .IsClientAuthRequired , this .isClientAuthRequired );
153- this .bFollowRedirects = getBooleanFromConfig ( ncc , CommonClientConfigKey .FollowRedirects , true );
154- this .ignoreUserToken = getBooleanFromConfig ( ncc , CommonClientConfigKey .IgnoreUserTokenInConnectionPoolForSecureClient , this .ignoreUserToken );
150+ this .isSecure = ncc . get ( CommonClientConfigKey .IsSecure , this .isSecure );
151+ this .isHostnameValidationRequired = ncc . get ( CommonClientConfigKey .IsHostnameValidationRequired , this .isHostnameValidationRequired );
152+ this .isClientAuthRequired = ncc . get ( CommonClientConfigKey .IsClientAuthRequired , this .isClientAuthRequired );
153+ this .bFollowRedirects = ncc . get ( CommonClientConfigKey .FollowRedirects , true );
154+ this .ignoreUserToken = ncc . get ( CommonClientConfigKey .IgnoreUserTokenInConnectionPoolForSecureClient , this .ignoreUserToken );
155155
156156 this .config = new DefaultApacheHttpClient4Config ();
157157 this .config .getProperties ().put (
158158 ApacheHttpClient4Config .PROPERTY_CONNECT_TIMEOUT ,
159- ncc .getOrDefault (CommonClientConfigKey .ConnectTimeout ));
159+ ncc .get (CommonClientConfigKey .ConnectTimeout ));
160160 this .config .getProperties ().put (
161161 ApacheHttpClient4Config .PROPERTY_READ_TIMEOUT ,
162- ncc .getOrDefault (CommonClientConfigKey .ReadTimeout ));
162+ ncc .get (CommonClientConfigKey .ReadTimeout ));
163163
164164 this .restClient = apacheHttpClientSpecificInitialization ();
165165 this .setRetryHandler (new HttpClientLoadBalancerErrorHandler (ncc ));
@@ -470,13 +470,6 @@ public HttpResponse execute(HttpRequest task, IClientConfig requestConfig) throw
470470 task .getHeaders (), task .getQueryParams (), config , task .getEntity ());
471471 }
472472
473-
474- private boolean getBooleanFromConfig (IClientConfig overriddenClientConfig , IClientConfigKey <Boolean > key , boolean defaultValue ) {
475- return Optional .ofNullable (overriddenClientConfig )
476- .map (config -> config .get (key ))
477- .orElse (defaultValue );
478- }
479-
480473 @ Override
481474 protected int getDefaultPortFromScheme (String scheme ) {
482475 int port = super .getDefaultPortFromScheme (scheme );
@@ -489,7 +482,7 @@ protected int getDefaultPortFromScheme(String scheme) {
489482
490483 @ Override
491484 protected Pair <String , Integer > deriveSchemeAndPortFromPartialUri (URI uri ) {
492- boolean isSecure = getBooleanFromConfig ( ncc , CommonClientConfigKey .IsSecure , this .isSecure );
485+ boolean isSecure = ncc . get ( CommonClientConfigKey .IsSecure , this .isSecure );
493486 String scheme = uri .getScheme ();
494487 if (scheme != null ) {
495488 isSecure = scheme .equalsIgnoreCase ("https" );
@@ -507,7 +500,7 @@ protected Pair<String, Integer> deriveSchemeAndPortFromPartialUri(URI uri) {
507500 scheme = "http" ;
508501 }
509502 }
510- return new Pair <String , Integer >(scheme , port );
503+ return new Pair <>(scheme , port );
511504 }
512505
513506 private HttpResponse execute (HttpRequest .Verb verb , URI uri ,
@@ -516,7 +509,7 @@ private HttpResponse execute(HttpRequest.Verb verb, URI uri,
516509 HttpClientResponse thisResponse = null ;
517510
518511 final boolean bbFollowRedirects = Optional .ofNullable (overriddenClientConfig )
519- .map (config -> config .get (CommonClientConfigKey .FollowRedirects , bFollowRedirects ))
512+ .flatMap (config -> config .getIfSet (CommonClientConfigKey .FollowRedirects ))
520513 .orElse (bFollowRedirects );
521514
522515 restClient .setFollowRedirects (bbFollowRedirects );
0 commit comments