Commit 544e2ce3 authored by wutu's avatar wutu

发现几处bug并修复

parent 1f84edba
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
*.iml *.iml
/bishe-utils/target/ /bishe-utils/target/
/bishe-edge-center/log/ /bishe-edge-center/log/
/.idea/
...@@ -148,8 +148,12 @@ public class ClusterServiceImpl implements ClusterService { ...@@ -148,8 +148,12 @@ public class ClusterServiceImpl implements ClusterService {
*/ */
@Override @Override
public Set<String> getContainerIdsByClusterId(long clusterId, String containerName) { public Set<String> getContainerIdsByClusterId(long clusterId, String containerName) {
// 做安全判断
if(clustersInfo.containsKey(clusterId)) {
return clustersInfo.get(clusterId).get(containerName); return clustersInfo.get(clusterId).get(containerName);
} }
return new HashSet<>();
}
/** /**
* @description 删除指定集群的全部容器 * @description 删除指定集群的全部容器
......
...@@ -62,6 +62,7 @@ public class DockerUtilsImpl implements DockerUtils { ...@@ -62,6 +62,7 @@ public class DockerUtilsImpl implements DockerUtils {
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
List<DockerContainer> dockerContainers = convertDockerResult(containers); List<DockerContainer> dockerContainers = convertDockerResult(containers);
dockerContainers.forEach(dockerContainer -> containersMap.put(dockerContainer.getId(), dockerContainer)); dockerContainers.forEach(dockerContainer -> containersMap.put(dockerContainer.getId(), dockerContainer));
return containersMap; return containersMap;
...@@ -74,7 +75,9 @@ public class DockerUtilsImpl implements DockerUtils { ...@@ -74,7 +75,9 @@ public class DockerUtilsImpl implements DockerUtils {
*/ */
public List<DockerContainer> convertDockerResult(List<Container> containers) { public List<DockerContainer> convertDockerResult(List<Container> containers) {
if(containers == null) { if(containers == null) {
throw new RuntimeException("容器列表不能为null"); LOG.warn("docker容器列表为null");
// 返回一个空的列表
return new ArrayList<>();
} }
List<DockerContainer> dockerContainers = new ArrayList<DockerContainer>(containers.size()); List<DockerContainer> dockerContainers = new ArrayList<DockerContainer>(containers.size());
containers.forEach(c -> { containers.forEach(c -> {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.2.RELEASE</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <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