File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
java/src/org/openqa/selenium/grid/server Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ public class BaseServerOptions {
41
41
42
42
private static final Logger LOG = Logger .getLogger (BaseServerOptions .class .getName ());
43
43
private final Config config ;
44
- private int port = -1 ;
45
44
46
45
public BaseServerOptions (Config config ) {
47
46
this .config = config ;
@@ -54,17 +53,14 @@ public Optional<String> getHostname() {
54
53
55
54
@ ManagedAttribute (name = "Port" )
56
55
public int getPort () {
56
+ int port = config .getInt (SERVER_SECTION , "port" )
57
+ .orElseGet (PortProber ::findFreePort );
57
58
if (port == -1 ) {
58
- int newPort = config .getInt (SERVER_SECTION , "port" )
59
- .orElseGet (PortProber ::findFreePort );
60
-
61
- if (newPort < 0 ) {
62
- throw new ConfigException ("Port cannot be less than 0: " + newPort );
63
- }
64
-
65
- port = newPort ;
59
+ return PortProber .findFreePort ();
60
+ }
61
+ if (port < 0 ) {
62
+ throw new ConfigException ("Port cannot be less than 0: " + port );
66
63
}
67
-
68
64
return port ;
69
65
}
70
66
You can’t perform that action at this time.
0 commit comments