Commit b8a477d
authored
fix: NPE in handleRecentResourceUpdate for an unknown secondary resource (#3519)
`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.1 parent 96e59cd commit b8a477d
2 files changed
Lines changed: 11 additions & 1 deletion
File tree
- operator-framework-core/src
- main/java/io/javaoperatorsdk/operator/processing/event/source
- test/java/io/javaoperatorsdk/operator/processing/event/source
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
215 | 225 | | |
216 | 226 | | |
217 | 227 | | |
| |||
0 commit comments