Skip to content

Commit

Permalink
fixup(discovery): check null
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Apr 26, 2024
1 parent 95c88f6 commit 5c94bb8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/io/cryostat/discovery/ContainerDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -62,6 +63,7 @@
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;

Expand Down Expand Up @@ -338,7 +340,7 @@ public void handleContainerEvent(List<ContainerSpec> current) {
DiscoveryNode.findAllByNodeType(BaseNodeType.JVM).stream()
.filter(
(n) ->
n.target != null
Objects.nonNull(n.target)
&& getRealm()
.equals(
n.target
Expand All @@ -349,7 +351,13 @@ && getRealm()
.collect(Collectors.toList());

Map<Target, ContainerSpec> containerRefMap = new HashMap<>();
current.forEach((desc) -> containerRefMap.put(toTarget(desc), desc));
current.stream()
.map((desc) -> Pair.of(desc, toTarget(desc)))
.filter((pair) -> Objects.nonNull(pair.getRight()))
.forEach(
(pair) ->
containerRefMap.put(
pair.getRight(), pair.getLeft()));

Set<Target> persistedTargets =
targetNodes.stream()
Expand Down

0 comments on commit 5c94bb8

Please sign in to comment.