Fix weird NotModifiedException bug (3.2.3)
This commit is contained in:
parent
ffbd44826b
commit
ae25560fb5
@ -1,6 +1,7 @@
|
||||
package dst.ass3.elastic.impl;
|
||||
|
||||
import com.github.dockerjava.api.DockerClient;
|
||||
import com.github.dockerjava.api.exception.NotModifiedException;
|
||||
import com.github.dockerjava.core.DockerClientBuilder;
|
||||
import dst.ass3.elastic.ContainerException;
|
||||
import dst.ass3.elastic.ContainerInfo;
|
||||
@ -26,15 +27,21 @@ public class ContainerService implements IContainerService {
|
||||
|
||||
@Override
|
||||
public void stopContainer(String containerId) throws ContainerException {
|
||||
containers.forEach(containerInfo -> {
|
||||
if (containerInfo.getContainerId().equals(containerId)) {
|
||||
containers.remove(containerInfo);
|
||||
dockerClient.stopContainerCmd(containerId).exec();
|
||||
dockerClient.removeContainerCmd(containerId).exec();
|
||||
return;
|
||||
boolean found = false;
|
||||
for (ContainerInfo info : containers) {
|
||||
if (info.getContainerId().equals(containerId)) {
|
||||
containers.remove(info);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
throw new ContainerNotFoundException("Container with id " + containerId + " not found");
|
||||
}
|
||||
|
||||
if (!found)
|
||||
throw new ContainerNotFoundException("Container with id " + containerId + " not found");
|
||||
try {
|
||||
dockerClient.stopContainerCmd(containerId).exec();
|
||||
} catch (NotModifiedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -10,8 +10,7 @@ public class ElasticityFactory implements IElasticityFactory {
|
||||
|
||||
@Override
|
||||
public IContainerService createContainerService() {
|
||||
// TODO
|
||||
return null;
|
||||
return new ContainerService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user