[ https://issues.apache.org/jira/browse/SLING-12640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rakesh Kumar updated SLING-12640: --------------------------------- Description: 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 was: 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 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 > 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)