Fix NPE in ManagedInformerEventSource#3332
Fix NPE in ManagedInformerEventSource#3332Donnerbart wants to merge 3 commits intooperator-framework:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a null-handling gap in the informer-managed update path where Fabric8 edit() can return null (notably on HTTP 404), which previously could lead to an NPE when updating the temporary resource cache. This aligns behavior with the reported issue #3331 (“patch target already deleted”).
Changes:
- Add a null guard in
ManagedInformerEventSource.eventFilteringUpdateAndCacheResourceto skip cache update when the update operation returnsnull. - Add regression tests covering
nullreturns from the update method at both the informer event source layer and viaResourceOperations.removeFinalizer. - Minor test refactors/formatting adjustments.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java | Adds null-guard around cache update after updateMethod.apply(...); also changes manager() visibility. |
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java | Adds regression test ensuring eventFilteringUpdateAndCacheResource cleanly propagates null. |
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/ResourceOperationsTest.java | Adds integration-style regression test for removeFinalizer when underlying patch/edit returns null. |
396094f to
d103e18
Compare
csviri
left a comment
There was a problem hiding this comment.
LGTM, thank you @Donnerbart
@shawkins if you have the bandwidth please take a look
@csviri @Donnerbart this assumption from the issue is not correct. The edit function throws an exception on 404. |
…emoval Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
…atch target is deleted Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
…of the returned class Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
d103e18 to
339b6c3
Compare
|
@shawkins You are correct, it looks like with a real K8s server the fabric8 client always throws on a 404. The The IT result indicates that the scope is just the mock server, so one option is to just close this PR and fix it upstream instead, in I fixed the reasoning in the PR, in case we still want a JOSDK-side guard. I can also refactor this PR to the other options I mention in the issue: fail loud with |
Fixes #3331