forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstrSyncDockerCmdExec.java
More file actions
33 lines (28 loc) · 1.14 KB
/
Copy pathAbstrSyncDockerCmdExec.java
File metadata and controls
33 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.github.dockerjava.core.exec;
import com.github.dockerjava.api.command.DockerCmd;
import com.github.dockerjava.api.command.DockerCmdSyncExec;
import com.github.dockerjava.api.exception.DockerException;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.WebTarget;
public abstract class AbstrSyncDockerCmdExec<CMD_T extends DockerCmd<RES_T>, RES_T> extends AbstrDockerCmdExec
implements DockerCmdSyncExec<CMD_T, RES_T> {
public AbstrSyncDockerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
super(baseResource, dockerClientConfig);
}
@Override
public RES_T exec(CMD_T command) {
// this hack works because of ResponseStatusExceptionFilter
try (CMD_T cmd = command) {
try {
return execute(cmd);
} catch (RuntimeException e) {
if (e.getCause() instanceof DockerException) {
throw (DockerException) e.getCause();
} else {
throw e;
}
}
}
}
protected abstract RES_T execute(CMD_T command);
}