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