[ 
https://issues.apache.org/jira/browse/SLING-12640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17922392#comment-17922392
 ] 

Rakesh Kumar edited comment on SLING-12640 at 1/30/25 2:44 PM:
---------------------------------------------------------------

thanks for the explnation [~cziegeler] 

but this statement is still fuzzy to me "{*}causing the {color:#ff0000}service 
to be completely ignored{color} if none of the values provided by the property 
are valid{*}."

let's say I just provide a single value which is invalid

 
{code:java}
{
  "sling.filter.scope": ["DISABLED"],
  "sling.filter.pattern": "/content/.*"
}{code}
as per the doc the filter service should have been ignored, right?

 

and if the provided value is invalid then why the filter is being registered 
via this code block.
{code:java}
if (!used) {
            log.warn(
                    "Filter service {} has been registered without a valid {} 
property. Using default value.",
                    serviceId,
                    EngineConstants.SLING_FILTER_SCOPE);
            getFilterChain(FilterChainType.REQUEST).addFilter(filter, 
predicate, serviceId, order, orderSource, mbean);
        }  {code}
 


was (Author: rakeshk15):
thanks for the explnation [~cziegeler] 

but this statement is still fuzzy to me "{*}causing the {color:#ff0000}service 
to be completely ignored{color} if none of the values provided by the property 
are valid{*}."

let's say I just provide a single value which is invalid

 
{code:java}
{
  "sling.filter.scope": ["DISABLED"],
  "sling.filter.pattern": "/content/.*"
}{code}
as per the doc the filter service should have been ignored, right?

 

> Setting Sling filter service property sling.filter.scope to an invalid value 
> does not disable the filter.
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-12640
>                 URL: https://issues.apache.org/jira/browse/SLING-12640
>             Project: Sling
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: Engine 2.15.16
>            Reporter: Rakesh Kumar
>            Priority: Major
>
> I have created a filter service and provided the value of 
> *sling.filter.scope* as some arbitrary string({*}MyDisabledFilter{*})
> I followed the disabling mechanism mentioned here - 
> [https://sling.apache.org/documentation/the-sling-engine/filters.html#disabling-filters-1]
> But the filter is still registered by Sling as a request filter.
> I was looking at the
> {code:java}
> org.apache.sling.engine.impl.filter.ServletFilterManager{code}
> code and found that if an invalid value is specified for *sling.filter.scope* 
> property, then the filter is still registered as a REQUEST scoped filter as 
> some fallback.
> {code:java}
> final String[] scopes =
>                 
> Converters.standardConverter().convert(scopeValue).to(String[].class);
>         final FilterPredicate predicate = new FilterPredicate(reference);
>         boolean used = false;
>         for (String scope : scopes) {
>             scope = scope.toUpperCase();
>             try {
>                 FilterChainType type = 
> FilterChainType.valueOf(scope.toString());
>                 getFilterChain(type).addFilter(filter, predicate, serviceId, 
> order, orderSource, mbean);
>                 if (type == FilterChainType.COMPONENT) {
>                     getFilterChain(FilterChainType.INCLUDE)
>                             .addFilter(filter, predicate, serviceId, order, 
> orderSource, mbean);
>                     getFilterChain(FilterChainType.FORWARD)
>                             .addFilter(filter, predicate, serviceId, order, 
> orderSource, mbean);
>                 }
>                 used = true;
>             } catch (final IllegalArgumentException iae) {
>                 log.warn("Filter service {} has invalid value {} for scope. 
> Value is ignored", reference, scope);
>             }
>         }
>         if (!used) {
>             log.warn(
>                     "Filter service {} has been registered without a valid {} 
> property. Using default value.",
>                     serviceId,
>                     EngineConstants.SLING_FILTER_SCOPE);
>             getFilterChain(FilterChainType.REQUEST).addFilter(filter, 
> predicate, serviceId, order, orderSource, mbean);
>         } {code}
>  
> This seems to be contradictory to the official documentation.
> Please let me know if I am missing something.
> [~cziegeler] can you please look at this?
> Thanks,
> Rakesh
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to