Skip to content

Commit c0fbec7

Browse files
committed
another possible use for comparable resource versions
1 parent a810ac9 commit c0fbec7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ public void handleRecentResourceCreate(ResourceID resourceID, R resource) {
133133

134134
@Override
135135
public Optional<R> get(ResourceID resourceID) {
136+
var res = cache.get(resourceID);
136137
Optional<R> resource = temporaryResourceCache.getResourceFromCache(resourceID);
137-
if (resource.isPresent()) {
138+
if (resource.isPresent() && res.filter(r -> r.getMetadata().getResourceVersion() < resource.get().getMetadata().getResourceVersion()).isPresent()) {
138139
log.debug("Resource found in temporary cache for Resource ID: {}", resourceID);
139140
return resource;
140141
} else {
141142
log.debug(
142143
"Resource not found in temporary cache reading it from informer cache,"
143144
+ " for Resource ID: {}",
144145
resourceID);
145-
var res = cache.get(resourceID);
146146
log.debug("Resource found in cache: {} for id: {}", res.isPresent(), resourceID);
147147
return res;
148148
}

0 commit comments

Comments
 (0)