Dennis-Mircea opened a new pull request, #1128:
URL: https://github.com/apache/flink-kubernetes-operator/pull/1128
## What is the purpose of the change
Both `SpecUtils.clone` and `DiffResult.toString` route data through a
redundant intermediate JSON String: they serialize an object to text and then
immediately parse that text back into an object or a tree. The String is never
used for anything else. This PR removes that hop by converting directly between
the object and its in-memory form. The meaningful win is `clone`, which runs on
every reconcile cycle for every managed resource.
## Brief change log
- `SpecUtils.clone` now uses `objectMapper.convertValue(object,
object.getClass())` instead of `readValue(writeValueAsString(object), ...)`,
converting object to tree to object without the String round-trip. Removes the
checked-exception handling that the String path required.
- `DiffResult.toString` now uses `objectMapper.valueToTree(...)` instead
of `readTree(writeValueAsString(...))` to build the before/after JSON trees for
the `SpecChanged` event message.
## Verifying this change
This change is already covered by existing tests, such as the reconciler
suites that exercise `ReconciliationUtils.clone` on the hot path (controller
and `AbstractFlinkResourceReconciler` tests) and the diff suites that exercise
`DiffResult.toString` (`ReflectiveDiffBuilder` tests). The change is behavior
preserving for the CRD and Fabric8 model types involved, which are JSON-native
and already round-tripped through JSON by Kubernetes.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changes to the `CustomResourceDescriptors`:
no
- Core observer or reconciler logic that is regularly executed: yes
(`SpecUtils.clone` is invoked per reconcile cycle via
`ReconciliationUtils.clone`)
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]