adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
730 stars 736 forks source link

[LatestVersionImplementationPicker] Implementation picker behavior causing issues and cannot be overriden #2595

Open vasseuke opened 10 months ago

vasseuke commented 10 months ago

Bug Report

Current Behavior LatestVersionImplementationPicker picks up custom implementation over core ones. I identified two issues caused by that behavior.

In both case, they trigger LatestVersionImplementationPicker instead of resource based and load our custom model which tries to inject (Self, Via) super type resource model.
Since resource context is missing superType, it triggers LatestVersionImplementationPicker again, injecting the custom implementation into itself, thus preventing methods delegation pattern. So we end up with the interface methods, returning null.

The consequences are that

Expected behavior/code I expect styles to be loaded on XF when using FE pipeline, and image dialog to not make a null pointer.

Environment

Possible Solution We considered 2 options:

I ended up choosing the second approach to tackle the problem at it's root. But ResourceBasedPicker and LatestVersionImplementationPicker are respectively ranked 0 and 1, leaving no space for a custom implementation. I added a custom implementation that ignores custom models Ranked 1 and since service id is higher, somehow it's being picked before LatestVersion but it's not a very reliable solution.

So i would suggest changing the rank of the LatestVersionImplementation to 10, or add some more configuration options.

But maybe you have better suggestions for me.