diff --git a/util/src/main/java/io/kubernetes/client/Discovery.java b/util/src/main/java/io/kubernetes/client/Discovery.java index eb621fd0e7..568f8a3879 100644 --- a/util/src/main/java/io/kubernetes/client/Discovery.java +++ b/util/src/main/java/io/kubernetes/client/Discovery.java @@ -116,7 +116,11 @@ private Map> manageRelationFromResourceToSubResources( getSubResourceNameIfPossible(r.getName()) .ifPresent( subResourceName -> { - subResources.get(getMajorResourceName(r.getName())).add(subResourceName); + subResources + .computeIfAbsent( + getMajorResourceName(r.getName()), + majorResourceName -> new HashSet<>()) + .add(subResourceName); }); }); return subResources;