You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Nicolas Peltier (Jira)" <ji...@apache.org> on 2021/03/02 17:54:00 UTC

[jira] [Commented] (SLING-10179) it should be made clearer that calling FilterChain.doFilter twice must not be done

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

Nicolas Peltier commented on SLING-10179:
-----------------------------------------

and the documentation is https://github.com/apache/sling-site/pull/56

> it should be made clearer that calling FilterChain.doFilter twice must not be done
> ----------------------------------------------------------------------------------
>
>                 Key: SLING-10179
>                 URL: https://issues.apache.org/jira/browse/SLING-10179
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: Engine 2.7.4
>            Reporter: Nicolas Peltier
>            Assignee: Nicolas Peltier
>            Priority: Minor
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Right now, calling FilterChain.doFilter twice will trigger an ArrayIndexOutOfBoundException (timer array based on the number of registered filter handles).
> Such (bad) code can trigger this:
> {Code}
> ...
>     filterChain.doFilter(...)
> ...
> if (wrongAssumption()) {
>    filterChain.doFilter(...);
> }
> ...
> {Code}
> it's not obvious for the developer from the ArrayIndexOutOfBoundException what he did wrong and i think we should 
> 1. either throw a servlet exception saying "Filter should not been called twice", either log a warning with the stack trace
> 2. document clearly in sling filters that filter should not be called twice, referring to both case (ArrayIndexOufOfBoundException and whatever comes out of 1.)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)