@@ -58,8 +58,6 @@ public class AppiumCommandExecutor extends HttpCommandExecutor {
5858
5959 private final Optional <DriverService > serviceOptional ;
6060 @ Getter
61- private final Factory httpClientFactory ;
62- @ Getter
6361 private final AppiumClientConfig appiumClientConfig ;
6462
6563 /**
@@ -81,7 +79,6 @@ public AppiumCommandExecutor(
8179 );
8280 serviceOptional = ofNullable (service );
8381
84- this .httpClientFactory = ofNullable (httpClientFactory ).orElseGet (HttpCommandExecutor ::getDefaultClientFactory );
8582 this .appiumClientConfig = appiumClientConfig ;
8683 }
8784
@@ -141,6 +138,10 @@ public Map<String, CommandInfo> getAdditionalCommands() {
141138 return getPrivateFieldValue (HttpCommandExecutor .class , "additionalCommands" , Map .class );
142139 }
143140
141+ public Factory getHttpClientFactory () {
142+ return getPrivateFieldValue (HttpCommandExecutor .class , "httpClientFactory" , Factory .class );
143+ }
144+
144145 @ Nullable
145146 protected CommandCodec <HttpRequest > getCommandCodec () {
146147 return this .commandCodec ;
@@ -165,8 +166,8 @@ protected HttpClient getClient() {
165166 * @param serverUrl A url to override.
166167 */
167168 protected void overrideServerUrl (URL serverUrl ) {
168- setPrivateFieldValue ( HttpCommandExecutor . class , "client" ,
169- this . httpClientFactory . createClient ( this . appiumClientConfig . baseUrl ( serverUrl )) );
169+ HttpClient newClient = getHttpClientFactory (). createClient ( appiumClientConfig . baseUrl ( serverUrl ));
170+ setPrivateFieldValue ( HttpCommandExecutor . class , "client" , newClient );
170171 }
171172
172173 private Response createSession (Command command ) throws IOException {
0 commit comments