You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Konrad Windszus <kw...@apache.org> on 2021/11/14 16:55:58 UTC
Null return values of o.a.s.spi.resource.provider.ResolveContext
Hi,
according to https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java all getter methods except for getResourceResolver() may return null.
Still e.g. in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/89bc0bb344d6c7f109f6e43ef5e87bda7c04d286/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java#L320 their return values are very often dereferenced unconditionally.
Are the null annotation values/javadoc incorrect here or are there just null checks missing in JcrResourceProvider?
This came up in the context of https://issues.apache.org/jira/browse/SLING-10918
Thanks in advance for your input,
Konrad
Re: Null return values of o.a.s.spi.resource.provider.ResolveContext
Posted by Konrad Windszus <ko...@gmx.de>.
Hi Carsten,
thanks for the answer. That makes a lot of sense :-)
Konrad
> On 15. Nov 2021, at 08:00, Carsten Ziegeler <cz...@apache.org> wrote:
>
> Hi,
>
> both (annotations and jcr code) are correct :)
>
> In the general case, the annotations in ResolveContext are correct and all those methods can return "null".
>
> However, for resource providers requiring authentication, getProviderState() will return the object returned by ResourceProvider#authenticate and the jcr resource provider can safely assume that it will get this object there. Therefore null checks are not necessary in the implementation
>
> Regards
> Carsten
>
> Am 14.11.2021 um 17:55 schrieb Konrad Windszus:
>> Hi,
>> according to https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java all getter methods except for getResourceResolver() may return null.
>> Still e.g. in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/89bc0bb344d6c7f109f6e43ef5e87bda7c04d286/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java#L320 their return values are very often dereferenced unconditionally.
>> Are the null annotation values/javadoc incorrect here or are there just null checks missing in JcrResourceProvider?
>> This came up in the context of https://issues.apache.org/jira/browse/SLING-10918
>> Thanks in advance for your input,
>> Konrad
>
> --
> Carsten Ziegeler
> Adobe
> cziegeler@apache.org
> aut
Re: Null return values of o.a.s.spi.resource.provider.ResolveContext
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
both (annotations and jcr code) are correct :)
In the general case, the annotations in ResolveContext are correct and
all those methods can return "null".
However, for resource providers requiring authentication,
getProviderState() will return the object returned by
ResourceProvider#authenticate and the jcr resource provider can safely
assume that it will get this object there. Therefore null checks are not
necessary in the implementation
Regards
Carsten
Am 14.11.2021 um 17:55 schrieb Konrad Windszus:
> Hi,
> according to https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java all getter methods except for getResourceResolver() may return null.
> Still e.g. in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/89bc0bb344d6c7f109f6e43ef5e87bda7c04d286/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java#L320 their return values are very often dereferenced unconditionally.
>
> Are the null annotation values/javadoc incorrect here or are there just null checks missing in JcrResourceProvider?
>
> This came up in the context of https://issues.apache.org/jira/browse/SLING-10918
>
> Thanks in advance for your input,
> Konrad
>
--
Carsten Ziegeler
Adobe
cziegeler@apache.org
aut