Commit 43bbdf4
fix: assorted robustness and clarity fixes (#3533)
* fix: assorted robustness and clarity fixes
Three unrelated small items found while auditing.
ManagedInformerEventSource.get could throw instead of falling back to the
informer cache. It compared a temporary-cache hit against
`manager().lastSyncResourceVersion(namespace)` without guarding either
failure mode:
* `lastSyncResourceVersion` is null until an informer has completed its
initial list, and `compareResourceVersions` dereferences it, so this
threw a NullPointerException.
* `InformerManager.lastSyncResourceVersion` does `getSource(ns)
.orElseThrow()`, which throws `NoSuchElementException` for a namespace
that is no longer watched after a dynamic namespace change - a window
that only closes on the next re-list, when `checkGhostResources` prunes
the entry.
`TemporaryResourceCache.putResource` already guards the null case; the
comparison is now extracted into a helper that guards both and falls back
to the informer cache, which is the safe answer in either case.
ExpectationResult.name() threw a bare NullPointerException when no
expectation was registered, which is a normal result state produced by
`ExpectationManager.checkExpectation`. It now throws
`IllegalStateException` pointing at `isExpectationPresent()`, and says so
in the javadoc.
ResourceOperations cleanups: drops the `options` parameter of
`desiredForJsonPatch`, which was never read at any of its six call sites,
and rewrites the comment on `create` - it claimed the operation "check if
the resource already exists", which it does not; the actual reason
filtering is safe is that the API server rejects a duplicate create.
* Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* fix
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
---------
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent b8a477d commit 43bbdf4
3 files changed
Lines changed: 46 additions & 13 deletions
File tree
- operator-framework-core/src/main/java/io/javaoperatorsdk/operator
- api/reconciler
- processing
- event/source/informer
- expectation
Lines changed: 11 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| |||
445 | 447 | | |
446 | 448 | | |
447 | 449 | | |
448 | | - | |
| 450 | + | |
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
| |||
556 | 558 | | |
557 | 559 | | |
558 | 560 | | |
559 | | - | |
| 561 | + | |
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
| |||
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | | - | |
| 585 | + | |
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
| |||
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
623 | | - | |
| 625 | + | |
624 | 626 | | |
625 | 627 | | |
626 | 628 | | |
| |||
645 | 647 | | |
646 | 648 | | |
647 | 649 | | |
648 | | - | |
| 650 | + | |
649 | 651 | | |
650 | 652 | | |
651 | 653 | | |
| |||
680 | 682 | | |
681 | 683 | | |
682 | 684 | | |
683 | | - | |
| 685 | + | |
684 | 686 | | |
685 | 687 | | |
686 | 688 | | |
| |||
717 | 719 | | |
718 | 720 | | |
719 | 721 | | |
720 | | - | |
| 722 | + | |
721 | 723 | | |
722 | 724 | | |
723 | 725 | | |
| |||
1447 | 1449 | | |
1448 | 1450 | | |
1449 | 1451 | | |
1450 | | - | |
| 1452 | + | |
1451 | 1453 | | |
1452 | 1454 | | |
1453 | 1455 | | |
| |||
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 227 | + | |
231 | 228 | | |
232 | 229 | | |
233 | 230 | | |
| |||
242 | 239 | | |
243 | 240 | | |
244 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
245 | 267 | | |
246 | 268 | | |
247 | 269 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
0 commit comments