fix: checking for null to avoid NPE with SSA matching by shawkins · Pull Request #3037 · operator-framework/java-operator-sdk

Pull Request Overview

This PR fixes a NullPointerException in the SSA (Server-Side Apply) based Kubernetes resource matcher when processing managed fields that reference collections that are null or missing in the actual resource. The fix adds null checks before dereferencing list values in two key methods.

Key changes:

  • Added null check in handleListKeyEntrySet to prevent NPE when actualValueList is null
  • Added null check in handleSetValues to prevent NPE when values is null
  • Added test case with a StatefulSet containing managed fields that reference missing values

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
SSABasedGenericKubernetesResourceMatcher.java Added null checks in handleListKeyEntrySet and handleSetValues methods to prevent NPE when referenced collections are missing
SSABasedGenericKubernetesResourceMatcherTest.java Added test case statefulSetWithMissingManagedField to verify matching works when managed fields reference missing values
statefulset-with-managed-fields-missing.yaml Added test resource file containing a StatefulSet with managed fields that reference potentially missing values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.