all right, than we're fine from that side. i will cross-check the nullability annotations for synthetic resource and the sling mock/resource resolver mocks to make sure they do not return null for resource type in unit tests.
stefan >-----Original Message----- >From: Carsten Ziegeler [mailto:cziege...@apache.org] >Sent: Thursday, January 9, 2020 10:45 PM >To: dev@sling.apache.org >Subject: Re: Resource Type mandatory or optional? > >I looked at some of our provider implementations and all of them make >sure to return a default resource type; so I think we're safe here. > >The only place where we potentially could handle this is inside the >resource resolver implementation after a resource is returned from a >provider. If the resource type is null, log a big error message and wrap >the resource. But on the other hand, a provider is then clearly breaking >the contract and there are other places where this could happen and we >don't check for that either, like if the resource returns the correct >path, the correct resource resolver etc. > >So as we don't have a problem here as of today, I think its not worth >doing any extra effort. > >Regards >Carsten > > >On 09.01.2020 22:08, Stefan Seifert wrote: >> to sum up the opinions: >> >> 1. Sling API should always return a resource type, even if it's a >fallback one >> >> 2. setting a sling:resourceType property is optional, if it's not set a >fallback resource type is returned >> >> 3. the JCR resource provider always uses the JCR primrary type as >fallback >> >> >> -> open question from my side: should we change the Sling API >implementation to always return a fixed fallback resource type, if the >resource provider does not provide any value for the resource type? konrad >recommended to use 'sling/servlet/default' to use for this purpose. >> >> >> stefan >> >> >>> -----Original Message----- >>> From: Stefan Seifert [mailto:sseif...@pro-vision.de] >>> Sent: Thursday, January 9, 2020 2:00 PM >>> To: Sling Developers >>> Subject: Resource Type mandatory or optional? >>> >>> 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 >>> >> >> > >-- >-- >Carsten Ziegeler >Adobe Research Switzerland >cziege...@apache.org