Skip to content

Commit b687cae

Browse files
committed
[java] Resetting the port to zero after using a service builder to allow reusing the same Builder
It is required for the grid that uses the single builder instantiated by service loader.
1 parent fd7c919 commit b687cae

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

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

364363
if (exe == null) {
@@ -367,7 +366,10 @@ public DS build() {
367366

368367
ImmutableList<String> args = createArgs();
369368

370-
return createDriverService(exe, portToUse, args, environment);
369+
DS service = createDriverService(exe, port, args, environment);
370+
port = 0; // reset port to allow reusing this builder
371+
372+
return service;
371373
}
372374

373375
protected abstract File findDefaultExecutable();

0 commit comments

Comments
 (0)