Skip to content

Commit dc80f18

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent e9ad24e commit dc80f18

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ public void changeNamespaces(Set<String> namespaces) {
8585
}
8686
}
8787

88-
/**
89-
* Updates the resource and makes sure that the response is available for the next reconciliation.
90-
* It does not filter the event produced by this update.
91-
*/
92-
public R updateAndCacheResource(R resourceToUpdate, UnaryOperator<R> updateMethod) {
93-
ResourceID id = ResourceID.fromResource(resourceToUpdate);
94-
var updated = updateMethod.apply(resourceToUpdate);
95-
handleRecentResourceUpdate(id, updated, resourceToUpdate);
96-
return updated;
97-
}
98-
9988
/**
10089
* Updates the resource and makes sure that the response is available for the next reconciliation.
10190
* Also makes sure that the even produced by this update is filtered, thus does not trigger the
@@ -106,23 +95,26 @@ public R eventFilteringUpdateAndCacheResource(R resourceToUpdate, UnaryOperator<
10695
if (log.isDebugEnabled()) {
10796
log.debug("Update and cache: {}", id);
10897
}
109-
R updatedResource = null;
98+
HasMetadata[] updatedResource = new HasMetadata[1];
11099
try {
111100
temporaryResourceCache.startEventFilteringModify(id);
112-
updatedResource = updateMethod.apply(resourceToUpdate);
113-
handleRecentResourceUpdate(id, updatedResource, resourceToUpdate);
114-
return updatedResource;
101+
updatedResource[0] = updateMethod.apply(resourceToUpdate);
102+
handleRecentResourceUpdate(id, (R) updatedResource[0], resourceToUpdate);
103+
return (R) updatedResource[0];
115104
} finally {
116105
var res =
117106
temporaryResourceCache.doneEventFilterModify(
118107
id,
119-
updatedResource == null ? null : updatedResource.getMetadata().getResourceVersion());
108+
updatedResource[0] == null
109+
? null
110+
: updatedResource[0].getMetadata().getResourceVersion());
111+
120112
res.ifPresent(
121113
r ->
122114
handleEvent(
123115
r.getAction(),
124116
(R) r.getResource().orElseThrow(),
125-
resourceToUpdate,
117+
(R) r.getResource().orElseThrow(), // todo handle this nicer for updates?
126118
!(r instanceof ResourceDeleteEvent)
127119
|| ((ResourceDeleteEvent) r).isDeletedFinalStateUnknown(),
128120
false));

0 commit comments

Comments
 (0)