One more clarification: Via the implicit resource super type 
"sling/servlet/default" technically each resource has a resource type which is 
used for rendering resources.

> On 9. Jan 2020, at 14:09, Konrad Windszus <[email protected]> wrote:
> 
> I tend to agree with the statement that the resource type should be optional. 
> Not every resource should be rendered and having no resource type set on 
> those resources feels natural to me.
> Enforcing a non-null resource type for every resource is more complicated as 
> each resource provider must be aware of it (even if you rarely have to deal 
> with it explicitly). For super types we explicitly have the default 
> "sling/servlet/default". I think we should make it the implicit resource type 
> as well (in case none is set, i.e. is null)
> In case there are issues in the code like NPEs for such resources, I would 
> rather fix those.
> 
> In any case the documentation at 
> https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-properties
>  should be clarified.
> 
> Konrad
> 
> 
>> On 9. Jan 2020, at 14:00, Stefan Seifert <[email protected]> wrote:
>> 
>> i've created a ticket concerning the Sling API that the method 
>> Resource.getResourceType should be marke das @Nullable, i always thought it 
>> was a bug and that the resource type is optional [1].
>> 
>> carsten pointed out that the resource type is mandatory. the javadocs are 
>> not precise on this, i've also found no clear statement in the sling docs (I 
>> might not have found it).
>> 
>> technically there is always a resource type when the JCR resource provider 
>> is used (fallback to JCR primary type if sling:resourceType is not set), but 
>> that's not implicitly the case for other resource providers or synthetic 
>> resources.
>> 
>> if we think a resource type should be never null, we should return a default 
>> value for resources that do not have one, and update the documentation.
>> 
>> WDYT?
>> 
>> stefan
>> 
>> [1] https://issues.apache.org/jira/browse/SLING-8975
>> 
> 

Reply via email to