Hi Jörg

In general, I agree that we could, and maybe should, evaluate which
types in the Sling API should be @ProviderType instead of
@ConsumerType. My assumption would be that most types should be
@ProviderType. I don't know what sort of versioning change adding the
@ProviderType annotation causes, however.

Regarding your specific case, I wonder if it would be acceptable to
remove the "putOnly" method, and instead modify the "put" method to
return "null" for in the case where a key was inserted, but the
supplier never evaluated. Of course that would change the behaviour,
so might cause issues in some edge cases.

Regards
Julian

On Mon, Jun 10, 2024 at 12:38 PM Jörg Hoh
<jhoh...@googlemail.com.invalid> wrote:
>
> Eric pointed out correctly, that there was tight connection between SLING
> API and Scripting core, as the package import range on scripting core
> (bundle version 2.4.8) is quite narrow for the package
> org.apache.sling.api.scripting:
>
> org.apache.sling.api.scripting; version="[2.5, 2.6)"
>
> This is caused by the class LazyBindings being a ConsumerType (
> https://github.com/apache/sling-org-apache-sling-api/blob/bdbd1768969917d0e2436d5b008fff80aaa729dc/src/main/java/org/apache/sling/api/scripting/LazyBindings.java#L56)
> and the scripting core inheriting from it (in ProtectedBindings).
>
> My latest extension to it (SLING-12062) then caused a bump of the exported
> version, thus breaking the existing imports.
>
> Of course I could do a release of the Scripting Core as well and make sure
> that it works with the package version as well, but I wonder if this is the
> right thing to do.
>
> Should the Sling API export ConsumerType interfaces and classes at all,
> which can cause this type of problems, or should we try to avoid them? This
> is a more general question; and in case that we want to avoid those, the
> question is still how we want to move forward with this specific instance
> of it.
>
> My personal opinion is
> * to avoid @ConsumerType exports in the Sling API in general and
> * move the ProtectedBindings class, which inherits from the LazyBindings
> over to the API
>
> that would allow us to have a wider import range on the scripting.core side.
>
> WDYT?
>
> Jörg
>
>
> --
> https://cqdump.joerghoh.de

Reply via email to