Skip to content

Commit

Permalink
fix: NPE with custom networks on shutdown.
Browse files Browse the repository at this point in the history
Fixes #1097
  • Loading branch information
rhuss committed Oct 1, 2018
1 parent d57c420 commit a725080
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/main/java/io/fabric8/maven/docker/StopMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,24 @@ private Set<Network> getNetworksToRemove(QueryService queryService, GavLabel gav
for (ImageConfiguration image : getResolvedImages()) {

final NetworkConfig config = image.getRunConfiguration().getNetworkingConfig();
if (!config.isCustomNetwork() || config.getName() == null) {
continue;
}
final Network network = getNetworkByName(networks, config.getCustomNetwork());
if (network == null) {
continue;
}
customNetworks.add(network);
Collection<Container> existingContainers =
ContainerNamingUtil.getContainersToStop(image,
containerNamePattern,
getBuildTimestamp(),
queryService.getContainersForImage(image.getName(), false));

if (config.isCustomNetwork() && network != null) {
customNetworks.add(network);
Collection<Container> existingContainers =
ContainerNamingUtil.getContainersToStop(image,
containerNamePattern,
getBuildTimestamp(),
queryService.getContainersForImage(image.getName(), false));

for (Container container : existingContainers) {
if (!shouldStopContainer(container, gavLabel)) {
// it's sill in use don't collect it
customNetworks.remove(network);
}
for (Container container : existingContainers) {
if (!shouldStopContainer(container, gavLabel)) {
// it's sill in use don't collect it
customNetworks.remove(network);
}
}
}
Expand Down

0 comments on commit a725080

Please sign in to comment.