33
33
import org .openqa .selenium .remote .http .HttpResponse ;
34
34
35
35
import java .io .IOException ;
36
- import java .net .MalformedURLException ;
37
36
import java .net .URL ;
38
37
import java .util .Map ;
39
38
@@ -58,7 +57,7 @@ public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs {
58
57
private LocalLogs logs = LocalLogs .getNullLogger ();
59
58
60
59
public HttpCommandExecutor (URL addressOfRemoteServer ) {
61
- this (emptyMap (), addressOfRemoteServer );
60
+ this (emptyMap (), Require . nonNull ( "Remote server address" , addressOfRemoteServer ) );
62
61
}
63
62
64
63
public HttpCommandExecutor (ClientConfig config ) {
@@ -76,7 +75,9 @@ public HttpCommandExecutor(
76
75
Map <String , CommandInfo > additionalCommands ,
77
76
URL addressOfRemoteServer )
78
77
{
79
- this (additionalCommands , addressOfRemoteServer , defaultClientFactory );
78
+ this (additionalCommands ,
79
+ Require .nonNull ("Remote server address" , addressOfRemoteServer ),
80
+ defaultClientFactory );
80
81
}
81
82
82
83
public HttpCommandExecutor (
@@ -85,7 +86,8 @@ public HttpCommandExecutor(
85
86
HttpClient .Factory httpClientFactory )
86
87
{
87
88
this (additionalCommands ,
88
- ClientConfig .defaultConfig ().baseUrl (addressOfRemoteServer ),
89
+ ClientConfig .defaultConfig ()
90
+ .baseUrl (Require .nonNull ("Remote server address" , addressOfRemoteServer )),
89
91
httpClientFactory );
90
92
}
91
93
@@ -94,18 +96,7 @@ public HttpCommandExecutor(
94
96
ClientConfig config ,
95
97
HttpClient .Factory httpClientFactory )
96
98
{
97
- try {
98
- if (config .baseUri () != null ) {
99
- remoteServer = config .baseUrl ();
100
- } else {
101
- remoteServer = new URL (
102
- System .getProperty ("webdriver.remote.server" , "http://localhost:4444/" ));
103
- config = config .baseUrl (remoteServer );
104
- }
105
- } catch (MalformedURLException e ) {
106
- throw new WebDriverException (e );
107
- }
108
-
99
+ remoteServer = Require .nonNull ("Remote server address" , config .baseUrl ());
109
100
this .additionalCommands = additionalCommands ;
110
101
this .httpClientFactory = httpClientFactory ;
111
102
this .client = httpClientFactory .createClient (config );
0 commit comments