Skip to content

Commit fd7c919

Browse files
committed
[java] Choosing a new random port on each invocation of build method in a driver service builder (if there is no port specified explicitly)
1 parent acb61e5 commit fd7c919

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

java/client/src/org/openqa/selenium/remote/service/DriverService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ protected File getLogFile() {
356356
* @return The new service object.
357357
*/
358358
public DS build() {
359-
if (port == 0) {
360-
port = PortProber.findFreePort();
359+
int portToUse = port;
360+
if (portToUse == 0) {
361+
portToUse = PortProber.findFreePort();
361362
}
362363

363364
if (exe == null) {
@@ -366,7 +367,7 @@ public DS build() {
366367

367368
ImmutableList<String> args = createArgs();
368369

369-
return createDriverService(exe, port, args, environment);
370+
return createDriverService(exe, portToUse, args, environment);
370371
}
371372

372373
protected abstract File findDefaultExecutable();

0 commit comments

Comments
 (0)