| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
A `BulkDependentResource` may implement any subset of `Creator`, `Updater` and `Deleter`. `BulkDependentResourceInstance`, the internal per-item wrapper that reuses `AbstractDependentResource`'s reconcile logic, implements all three and delegates each call to the bulk resource with an unchecked cast. Its capabilities therefore have to be derived from the wrapped bulk resource. 0b8d8dd introduced the overridable `creatable()` / `updatable()` hooks for exactly this, but the wiring was never completed: * `BulkDependentResourceInstance` overrides `isCreatable()` / `isUpdatable()`, which `reconcile` never consults, so both overrides were dead code. * the inner create branch of `AbstractDependentResource.reconcile` still read the `creatable` field directly instead of calling `creatable()`. Since the wrapper implements all three interfaces, both fields are always true, so create and update were attempted regardless of what the bulk resource actually supports, failing with a ClassCastException in `BulkDependentResourceInstance.create` / `update`: java.lang.ClassCastException: class ...CreateAndDeleteOnlyBulk cannot be cast to class ...Updater at BulkDependentResourceInstance.update(BulkDependentResourceReconciler.java:115) at AbstractDependentResource.handleUpdate(AbstractDependentResource.java:204) A non-bulk dependent in the same situation just logs "implement Updater interface to modify it" and skips the operation. Fixes this by overriding `creatable()` / `updatable()` in the wrapper and by using `creatable()` in the create branch. `isCreatable()` / `isUpdatable()` now delegate to `creatable()` / `updatable()` so the two pairs cannot drift apart again. Adds regression tests for a create+delete-only and a delete-only bulk dependent; both fail without this change.
There was a problem hiding this comment.
Fixes reconciliation for bulk dependents so create/update operations are only attempted when the wrapped BulkDependentResource actually supports them, preventing ClassCastException from the per-item wrapper incorrectly advertising capabilities.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractDependentResource.java | Ensures reconciliation uses creatable()/updatable() hooks consistently so capability overrides are honored. |
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/BulkDependentResourceReconciler.java | Derives per-item wrapper create/update capabilities from the wrapped bulk resource to avoid invalid casts. |
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/BulkDependentResourceCapabilitiesTest.java | Adds regression coverage for bulk resources that intentionally do not implement Creator and/or Updater. |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
A BulkDependentResource may implement any subset of Creator,
Updater and Deleter. BulkDependentResourceInstance, the internal
per-item wrapper that reuses AbstractDependentResource's reconcile
logic, implements all three and delegates each call to the bulk resource
with an unchecked cast. Its capabilities therefore have to be derived
from the wrapped bulk resource.
0b8d8dd introduced the overridable creatable() / updatable() hooks
for exactly this, but the wiring was never completed:
isUpdatable(), which reconcile never consults, so both overrides
were dead code.
read the creatable field directly instead of calling creatable().
Since the wrapper implements all three interfaces, both fields are always
true, so create and update were attempted regardless of what the bulk
resource actually supports, failing with a ClassCastException in
BulkDependentResourceInstance.create / update:
A non-bulk dependent in the same situation just logs "implement Updater
interface to modify it" and skips the operation.
Fixes this by overriding creatable() / updatable() in the wrapper and
by using creatable() in the create branch. isCreatable() /
isUpdatable() now delegate to creatable() / updatable() so the two
pairs cannot drift apart again.
Adds regression tests for a create+delete-only and a delete-only bulk
dependent; both fail without this change.
Part of #3517