Hi Felix,

I saw this briefly. This comes if I try to use web console to see the list of 
features.

In that case, if the isEnabled depends on resourceResolver that will perhaps 
fails.

Thanks,
-Amit

-----Original Message-----
From: Felix Meschberger [mailto:fmesc...@adobe.com] 
Sent: 06 February 2014 16:07
To: dev@sling.apache.org
Subject: Re: [featureflags] NPE in context.getResourceResolver()

Hi

Am 06.02.2014 um 11:18 schrieb Simone Tripodi <simonetrip...@apache.org>:

> Hi all mates,
> 
> A colleague of mine just let me notice that from the sling 
> ExecutionContextImpl implementation, it seems like resourceResolver 
> could be null,

Well yes, that is how ExecutionContext.getResourceResolver is defined:

>     /**
>      * Returns a {@code ResourceResolver} object to retrieve information which
>      * may influence the decision whether a {@link Feature} is enabled or not.
>      * If a {@code ResourceResolver} object is not available in the context,
>      * this method may return {@code null}.
>      *
>      * @return the resource resolver or {@code null}
>      */
>     ResourceResolver getResourceResolver();
> 


> SlingAuthenticator gets control after the Feature's filter & sets the 
> resolver...

Can you provide a stack trace ? Thanks.

> 
> Is there any way we can obtain the ResourceResolver before Feature's 
> filter is invoked?

The implementation is that the FeatureManager as a Filter is called before the 
actual servlet (e.g. SlingMainServlet) is called for request processing. This 
should actually also happen after authentication is handled.

The FeatureManager filter tries to extract the ResourceResolver from the 
request attribute which is expected to be set by the Sling Authenticator. If 
the request attribute is not available (or not a ResourceResolver instance), 
the ExecutionCOntext will not provide a resource resolver.

Regards
Felix


> 
> Many thanks in advance, all the best!
> -Simo
> 
> http://people.apache.org/~simonetripodi/
> http://twitter.com/simonetripodi

Reply via email to