Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@

public interface DockerCmd<RES_T> extends Closeable {

@Override
public void close();

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public <T extends ResultCallback<A_RES_T>> T exec(T resultCallback) {
}

@Override
public void close() throws IOException {
public void close() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RES_T exec() throws DockerException {
}

@Override
public void close() throws IOException {
public void close() {
}

protected String registryAuth(AuthConfig authConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfigs) {
}

@Override
public void close() throws IOException {
public void close() {
super.close();

tarInputStream.close();
try {
tarInputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ public void onError(Throwable throwable) {
@Override
public void onComplete() {
resultCallback.onComplete();
try {
command.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
command.close();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,17 @@ public AbstrSyncDockerCmdExec(WebTarget baseResource) {
@Override
public RES_T exec(CMD_T command) {
// this hack works because of ResponseStatusExceptionFilter
RES_T result;
try {
result = execute(command);

} catch (ProcessingException e) {
if (e.getCause() instanceof DockerException) {
throw (DockerException) e.getCause();
} else {
throw e;
}
} finally {
try (CMD_T cmd = command) {
try {
command.close();
} catch (IOException e) {
throw new RuntimeException(e);
return execute(cmd);
} catch (ProcessingException e) {
if (e.getCause() instanceof DockerException) {
throw (DockerException) e.getCause();
} else {
throw e;
}
}
}

return result;
}

protected abstract RES_T execute(CMD_T command);
Expand Down