Skip to content

Commit

Permalink
[java] Resetting the port to zero after using a service builder to al…
Browse files Browse the repository at this point in the history
…low reusing the same Builder

It is required for the grid that uses the single builder instantiated by service loader.
  • Loading branch information
barancev committed Sep 25, 2019
1 parent fd7c919 commit b687cae
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,8 @@ protected File getLogFile() {
* @return The new service object.
*/
public DS build() {
int portToUse = port;
if (portToUse == 0) {
portToUse = PortProber.findFreePort();
if (port == 0) {
port = PortProber.findFreePort();
}

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

ImmutableList<String> args = createArgs();

return createDriverService(exe, portToUse, args, environment);
DS service = createDriverService(exe, port, args, environment);
port = 0; // reset port to allow reusing this builder

return service;
}

protected abstract File findDefaultExecutable();
Expand Down

0 comments on commit b687cae

Please sign in to comment.