Closed
Description
If I have an dependentResource that extends from AbstractExternalDependentResource
, but also from Updater
, then the update
will never be called when the Primary resource is updated. This is caused by a problem with the match
method.
For example this dependent resource:
public class ExternalUserDependentResource
extends PerResourcePollingDependentResource<ExternalUser, MyPrimary>
implements Creator<ExternalUser, MyPrimary>,
Deleter<MyPrimary>,
Updater<ExternalUser, MyPrimary> {
// ...
@Override
protected ExternalUser desired(MyPrimary primary, Context<MyPrimary> context) {
return new ExternalUser(primary.getSpec().username());
}
@Override
public ExternalUser create(ExternalUser desired, MyPrimary primary, Context<Prim> context) {
externalSystem.create(desired.username());
return desired;
}
@Override
public ExternalUser update(ExternalUser actual, ExternalUser desired, MyPrimary primary, Context<MyPrimary> context) {
externalSystem.update(desired.username());
return desired;
}
@Override
public Set<ExternalUser> fetchResources(MyPrimary primary) {
return externalSystem
.findUsers(primary.getSpec().username())
.map(u -> new ExternalUser(u.username())
.collect(toSet());
}
}
This is caused by a method call to match
that keeps calling itself:
AbstractDependentResource::match
is called:
public Result<R> match(R resource, P primary, Context<P> context) {
return updater.match(resource, primary, context);
}
- It calls the
match
method on the fieldupdater
, but this is the same dependent resource (ExternalUserDependentResource
in my example):
protected AbstractDependentResource() {
creator = creatable ? (Creator<R, P>) this : null;
updater = updatable ? (Updater<R, P>) this : null;
- Stuck in a loop
Workaround:
Override match
in the dependent resource and do the check yourself.
Metadata
Metadata
Assignees
Labels
No labels