You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2009/10/15 16:08:31 UTC

[jira] Commented: (SLING-1003) Integration of 3rd party servlet filters problematic

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

Felix Meschberger commented on SLING-1003:
------------------------------------------

I have finally found some time to look closer into this issue ...

The problem is as follows - and Sling should really cope with it better: The WebCastellum filter wraps the request and response, which is ok and expected. But it wraps them with HttpServletRequest/Response. Now if any downstream filter makes use of a SlingHttpServletRequest/Response, this fails with a ClassCastException.

Internestingly at the end of the filter chain, the request and response variables are ensured to be Sling instances again. The probable fix is to ensure on each entry into the AbstractSlingFilterChain.doFilter method that the request and response are the Sling ones.

> Integration of 3rd party servlet filters problematic
> ----------------------------------------------------
>
>                 Key: SLING-1003
>                 URL: https://issues.apache.org/jira/browse/SLING-1003
>             Project: Sling
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: Engine 2.0.4
>         Environment: Windows Vista, 
> java version "1.6.0_13"
> Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
> Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
>            Reporter: Christian Sprecher
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: Engine 2.1.0
>
>         Attachments: RequestData.diff, SlingWebCastellum-1.0.jar
>
>
> There is a problem within the chain handling: the 3rd party filter uses it's own wrapper for requests and response, and supplies it to the chain in the chain.doFilter() call. This leads to a ClassCastException on line 54 of AbstractSlingFilterChain:
> ...
>            RequestProgressTracker tracker = ((SlingHttpServletRequest) request).getRequestProgressTracker();
> ...
> I am not sure if this cast is valid in the context of a filter chain. On the other hand I am not sure wether such a use case (filter that manipulates request and response) has a chance to run in Sling.
> ==> Please note that this servlet filter needs to run as early as possible in the filter chain
> java.lang.ClassCastException: org.webcastellum.RequestWrapper cannot be cast to
> org.apache.sling.api.SlingHttpServletRequest
>        at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter
> (AbstractSlingFilterChain.java:54)
>        at org.webcastellum.WebCastellumFilter.internalDoFilter(WebCastellumFilt
> er.java:2610)
>        at org.webcastellum.WebCastellumFilter.doFilter(WebCastellumFilter.java:
> 1710)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.