Skip to content

Commit 9a6c28c

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 38e7265 commit 9a6c28c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,12 @@ public void handleRecentResourceCreate(ResourceID resourceID, R resource) {
186186

187187
@Override
188188
public Optional<R> get(ResourceID resourceID) {
189-
// The order of these two lookups matters. If we queried the informer cache first,
190-
// a race condition could occur: we might not find the resource there yet, then
191-
// process an informer event that evicts the temporary resource cache entry. At that
192-
// point the resource would already be present in the informer cache, but we would
193-
// have missed it in both caches during this call.
194-
Optional<R> resource = temporaryResourceCache.getResourceFromCache(resourceID);
195-
if (comparableResourceVersions && resource.isPresent()) {
196-
log.debug("Latest resource found in temporary cache for Resource ID: {}", resourceID);
197-
return resource;
189+
if (comparableResourceVersions) {
190+
Optional<R> resource = temporaryResourceCache.getResourceFromCache(resourceID);
191+
if (resource.isPresent()) {
192+
log.debug("Latest resource found in temporary cache for Resource ID: {}", resourceID);
193+
return resource;
194+
}
198195
}
199196
var res = cache.get(resourceID);
200197
log.debug(

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/TemporaryResourceCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private void setLatestResourceVersion(T resource) {
263263
} else {
264264
perNamespaceLatestResourceVersion.put(
265265
resource.getMetadata().getNamespace(), resource.getMetadata().getResourceVersion());
266-
log.debug("Setting latest resource version to: {} for namesoace", latestResourceVersion);
266+
log.debug("Setting latest resource version to: {} for namespace", latestResourceVersion);
267267
}
268268
}
269269

0 commit comments

Comments
 (0)