Commit 544e2ce3 authored by wutu's avatar wutu

发现几处bug并修复

parent 1f84edba
......@@ -2,3 +2,4 @@
*.iml
/bishe-utils/target/
/bishe-edge-center/log/
/.idea/
......@@ -148,7 +148,11 @@ public class ClusterServiceImpl implements ClusterService {
*/
@Override
public Set<String> getContainerIdsByClusterId(long clusterId, String containerName) {
return clustersInfo.get(clusterId).get(containerName);
// 做安全判断
if(clustersInfo.containsKey(clusterId)) {
return clustersInfo.get(clusterId).get(containerName);
}
return new HashSet<>();
}
/**
......
......@@ -62,6 +62,7 @@ public class DockerUtilsImpl implements DockerUtils {
} catch (InterruptedException e) {
e.printStackTrace();
}
List<DockerContainer> dockerContainers = convertDockerResult(containers);
dockerContainers.forEach(dockerContainer -> containersMap.put(dockerContainer.getId(), dockerContainer));
return containersMap;
......@@ -74,7 +75,9 @@ public class DockerUtilsImpl implements DockerUtils {
*/
public List<DockerContainer> convertDockerResult(List<Container> containers) {
if(containers == null) {
throw new RuntimeException("容器列表不能为null");
LOG.warn("docker容器列表为null");
// 返回一个空的列表
return new ArrayList<>();
}
List<DockerContainer> dockerContainers = new ArrayList<DockerContainer>(containers.size());
containers.forEach(c -> {
......
......@@ -19,6 +19,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.2.RELEASE</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment