File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
java/server/src/org/openqa/selenium/grid/server Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 17
17
18
18
package org .openqa .selenium .grid .server ;
19
19
20
+ import org .openqa .selenium .WebDriverException ;
20
21
import org .openqa .selenium .grid .config .Config ;
21
22
import org .openqa .selenium .grid .config .ConfigException ;
23
+ import org .openqa .selenium .net .HostIdentifier ;
22
24
import org .openqa .selenium .net .NetworkUtils ;
23
25
import org .openqa .selenium .net .PortProber ;
24
26
25
27
import java .net .URI ;
26
28
import java .net .URISyntaxException ;
27
29
import java .util .Optional ;
30
+ import java .util .logging .Logger ;
28
31
29
32
public class BaseServerOptions {
30
33
34
+ private static final Logger LOG = Logger .getLogger (BaseServerOptions .class .getName ());
31
35
private final Config config ;
32
36
private int port = -1 ;
33
37
@@ -70,7 +74,15 @@ public int getMaxServerThreads() {
70
74
public URI getExternalUri () {
71
75
// Assume the host given is addressable if it's been set
72
76
String host = getHostname ()
73
- .orElseGet (() -> new NetworkUtils ().getNonLoopbackAddressOfThisMachine ());
77
+ .orElseGet (() -> {
78
+ try {
79
+ return new NetworkUtils ().getNonLoopbackAddressOfThisMachine ();
80
+ } catch (WebDriverException e ) {
81
+ String name = HostIdentifier .getHostName ();
82
+ LOG .info ("No network connection, guessing name: " + name );
83
+ return name ;
84
+ }
85
+ });
74
86
75
87
int port = getPort ();
76
88
You can’t perform that action at this time.
0 commit comments