Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Component#getData performance by re-using ObjectMapper #1381

Open
dhardtke opened this issue Feb 6, 2021 · 0 comments · May be fixed by #1382
Open

Improve Component#getData performance by re-using ObjectMapper #1381

dhardtke opened this issue Feb 6, 2021 · 0 comments · May be fixed by #1382
Labels
enhancement New feature, or improvement to an existing feature.

Comments

@dhardtke
Copy link
Contributor

dhardtke commented Feb 6, 2021

Feature Request

Is your feature request related to a problem? Please describe.
No problem. Just an observation.

Describe the solution you'd like
Right now com.adobe.cq.wcm.core.components.internal.models.v1.datalayer.ComponentDataImpl#getJson constructs a new ObjectMapper for each invocation of the method.

Additionally, the configuration of the serializer in com.adobe.cq.wcm.core.components.models.Component#getData should be moved inside of com.adobe.cq.wcm.core.components.internal.models.v1.datalayer.ComponentDataImpl#getJson because right now a build-warning is generated since ComponentData is part of the public API (inside Export-Package) but com.adobe.cq.wcm.core.components.internal.jackson.ComponentDataModelSerializer is inside internal.

Are there alternatives?
The construction per invocation of getJsonis unnecessary as ObjectMapper is thread-safe (as long as no configuration changes occur after constructing the object).

Alternatively or even better we can switch to ObjectWriter since we only use Jackson to serialize the Data for the JavaScript to consume as ObjectWriter is guaranteed to be immutable.

Documentation

dhardtke added a commit to dhardtke/aem-core-wcm-components that referenced this issue Feb 6, 2021
…#1381)

Also moves the configuration of ComponentData's serializer inside ComponentDataImpl
dhardtke added a commit to dhardtke/aem-core-wcm-components that referenced this issue Feb 6, 2021
dhardtke added a commit to dhardtke/aem-core-wcm-components that referenced this issue Feb 6, 2021
…#1381)

Also moves the configuration of ComponentData's serializer inside ComponentDataImpl
dhardtke added a commit to dhardtke/aem-core-wcm-components that referenced this issue Feb 6, 2021
@richardhand richardhand added the enhancement New feature, or improvement to an existing feature. label Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, or improvement to an existing feature.
Projects
None yet
2 participants