From 0b2e287740d5536850996b392b85ad12e785c836 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Tue, 14 Jun 2016 15:15:46 -0700 Subject: [PATCH] Address second round of PR feedback --- .../ConflictingContainerRemovingDockerCompose.java | 14 +++----------- .../compose/execution/DelegatingDockerCompose.java | 9 +++++++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/palantir/docker/compose/execution/ConflictingContainerRemovingDockerCompose.java b/src/main/java/com/palantir/docker/compose/execution/ConflictingContainerRemovingDockerCompose.java index 4aa742c83..29ddf60ed 100644 --- a/src/main/java/com/palantir/docker/compose/execution/ConflictingContainerRemovingDockerCompose.java +++ b/src/main/java/com/palantir/docker/compose/execution/ConflictingContainerRemovingDockerCompose.java @@ -46,11 +46,9 @@ public ConflictingContainerRemovingDockerCompose(DockerCompose dockerCompose, Do @Override public void up() throws IOException, InterruptedException { - int currRetryAttempt = 0; - - while (true) { + for (int currRetryAttempt = 0; currRetryAttempt <= retryAttempts; currRetryAttempt++) { try { - super.up(); + getDockerCompose().up(); return; } catch (DockerExecutionException e) { Set conflictingContainerNames = getConflictingContainerNames(e.getMessage()); @@ -59,16 +57,10 @@ public void up() throws IOException, InterruptedException { throw e; } - if (currRetryAttempt == retryAttempts) { - break; - } - log.debug("docker-compose up failed due to container name conflicts (container names: {}). " - + "Removing containers and attempting docker-compose up again (attempt {}).", + + "Removing containers and attempting docker-compose up again (attempt {}).", conflictingContainerNames, currRetryAttempt + 1); removeContainers(conflictingContainerNames); - - currRetryAttempt++; } } diff --git a/src/main/java/com/palantir/docker/compose/execution/DelegatingDockerCompose.java b/src/main/java/com/palantir/docker/compose/execution/DelegatingDockerCompose.java index c09fa3855..3ea17adb4 100644 --- a/src/main/java/com/palantir/docker/compose/execution/DelegatingDockerCompose.java +++ b/src/main/java/com/palantir/docker/compose/execution/DelegatingDockerCompose.java @@ -21,10 +21,10 @@ import java.io.IOException; import java.io.OutputStream; -public abstract class DelegatingDockerCompose implements DockerCompose { +abstract class DelegatingDockerCompose implements DockerCompose { private final DockerCompose dockerCompose; - public DelegatingDockerCompose(DockerCompose dockerCompose) { + protected DelegatingDockerCompose(DockerCompose dockerCompose) { this.dockerCompose = dockerCompose; } @@ -78,4 +78,9 @@ public boolean writeLogs(String container, OutputStream output) throws IOExcepti public Ports ports(String service) throws IOException, InterruptedException { return dockerCompose.ports(service); } + + protected final DockerCompose getDockerCompose() { + return dockerCompose; + } + }