Skip to content

Commit

Permalink
[java] Choosing a new random port on each invocation of build method …
Browse files Browse the repository at this point in the history
…in a driver service builder (if there is no port specified explicitly)
  • Loading branch information
barancev committed Sep 25, 2019
1 parent acb61e5 commit fd7c919
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ protected File getLogFile() {
* @return The new service object.
*/
public DS build() {
if (port == 0) {
port = PortProber.findFreePort();
int portToUse = port;
if (portToUse == 0) {
portToUse = PortProber.findFreePort();
}

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

ImmutableList<String> args = createArgs();

return createDriverService(exe, port, args, environment);
return createDriverService(exe, portToUse, args, environment);
}

protected abstract File findDefaultExecutable();
Expand Down

0 comments on commit fd7c919

Please sign in to comment.