| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
`ExternalResourceCachingEventSource.handleRecentResourceUpdate` checks
that the primary has an entry in the cache, but then dereferences the
per-secondary lookup without checking it:
R actualResource = actualValues.get(resourceId);
if (actualResource.equals(previousVersionOfResource)) {
`actualValues.get(resourceId)` returns null whenever the primary has a
cache entry but that particular secondary id is not in it, which throws a
NullPointerException. This is reachable from
`AbstractEventSourceHolderDependentResource.onUpdated` for any
`RecentOperationCacheFiller` event source, e.g. after an update whose
resource id is not the one currently cached for that primary.
Skips the cache update when the resource is not tracked, which matches
the intent of the surrounding "only overwrite if we still hold the
version the caller saw" check.
Adds a regression test that fails with NullPointerException without this
change.
There was a problem hiding this comment.
Fixes a NullPointerException in ExternalResourceCachingEventSource.handleRecentResourceUpdate when a primary is cached but the specific secondary resource ID is not tracked, aligning behavior with the intended “only overwrite if the cached value matches the caller’s previous version” semantics.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/ExternalResourceCachingEventSource.java | Adds a null check before comparing cached vs previous resource to prevent NPE and skip untracked secondary updates. |
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/ExternalResourceCachingEventSourceTest.java | Adds a regression test covering the “unknown secondary ID” update scenario. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
ExternalResourceCachingEventSource.handleRecentResourceUpdate checks
that the primary has an entry in the cache, but then dereferences the
per-secondary lookup without checking it:
R actualResource = actualValues.get(resourceId); if (actualResource.equals(previousVersionOfResource)) {actualValues.get(resourceId) returns null whenever the primary has a
cache entry but that particular secondary id is not in it, which throws a
NullPointerException. This is reachable from
AbstractEventSourceHolderDependentResource.onUpdated for any
RecentOperationCacheFiller event source, e.g. after an update whose
resource id is not the one currently cached for that primary.
Skips the cache update when the resource is not tracked, which matches
the intent of the surrounding "only overwrite if we still hold the
version the caller saw" check.
Adds a regression test that fails with NullPointerException without this
change.
Part of #3517