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

Carsten Ziegeler commented on SLING-12640:
------------------------------------------

Good point, it seems our documentation did never match the implementation. 
Before [1]  the filter was registered as REQUEST if no value was provided - 
that is clearly wrong. After [1] we still do this but also register it if all 
provided values are invalid. The "used=true" statement needs to be executed 
regardless of whether the value is valid or not - then we should have the old 
behaviour back - which is still not what is documented

[1] 
https://github.com/apache/sling-org-apache-sling-engine/commit/31eafb67fc0514cf39aea8208c16b87916bc8882#diff-c7d29794f5f0df0ba8bd0758b2b9853d84c5a9a87bd1b164e14448854292601c

> 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