You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Christian Sprecher (JIRA)" <ji...@apache.org> on 2009/06/12 07:22:07 UTC
[jira] Created: (SLING-1003) Integration of 3rd party servlet
filters problematic
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
Priority: Minor
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.
[jira] Resolved: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger resolved SLING-1003.
--------------------------------------
Resolution: Fixed
Fix Version/s: Engine 2.0.6
Thanks for reporting the bug.
Fixed the AbstractSlingFilterChain to cope with non-SlingHttpServletRequest/Response objects in Rev. 784140.
Please close this issue if this solves your problem. Thanks.
> 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.0.6
>
>
> 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.
[jira] Commented: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720115#action_12720115 ]
Felix Meschberger commented on SLING-1003:
------------------------------------------
Hmm, it looks like the SlingHttpServletRequest/ResponseAdapter classes are calling just getRequest/Response which returns the wrapped HttpServletRequest/Response which of course cannot be cast.
So we have to overwrite the getSlingRequest/Response methods in the adapters to ensure the baseclass getRequest/Response mehod is called, which then is the SlingHttpServlet/Request/Response.
Applied a fix in Rev. 785200.
Can you please check ? Thanks.
> 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.0.6
>
> Attachments: 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.
[jira] Reopened: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Christian Sprecher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Christian Sprecher reopened SLING-1003:
---------------------------------------
see comments above
> 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.0.6
>
> Attachments: 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.
[jira] Assigned: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger reassigned SLING-1003:
----------------------------------------
Assignee: Felix Meschberger
> 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
>
> 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.
[jira] Updated: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Christian Sprecher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Christian Sprecher updated SLING-1003:
--------------------------------------
Attachment: SlingWebCastellum-1.0.jar
The corpus delicti: OSGI-fied WebCastellum version. Creates a Component named
org.webcastellum.WebCastellumFilter, which needs to be started explicitely
> 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.0.6
>
> Attachments: 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.
[jira] Commented: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Christian Sprecher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720162#action_12720162 ]
Christian Sprecher commented on SLING-1003:
-------------------------------------------
To be honest, I cannot follow you there :). But anyways:
I do see
java.lang.ClassCastException: org.webcastellum.RequestWrapper cannot be cast to org.apache.sling.api.SlingHttpServletRequest
at org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper.getSlingRequest(SlingHttpServletRequestWrapper.java:56)
at org.apache.sling.engine.impl.request.RequestData.unwrap(RequestData.java:317)
When I look at your change:
@Override
+ public SlingHttpServletRequest getSlingRequest() {
+ // overwrite base class getSlingRequest since that method
+ // calls getRequest which is overwritten here to return the
+ // HttpServletRequest - we have to get the actual underlying
+ // request object which is available from the base class
+ return (SlingHttpServletRequest) super.getRequest();
+ }
You still cast it onto SlingHttpServletRequest, why?
I do not know enough of the source code, but maybe a hint:
When I debug the whole stuff in RequestData#unwrap, I do see the following thing:
request.getRequest() ==> org.webcastellum.RequestWrapper@97eb44
request.getRequest().getRequest() ==> org.apache.sling.engine.impl.SlingHttpServletRequestImpl@1a60a71
So I *think* (wild guessing of course), that we are interested in the later result when unwrapping. The WebCastellum filter itself already wrapps the (Sling)Request in a custom wrapper.
Sorry to be such a pain, and thx in advance
> 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.0.6
>
> Attachments: 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.
[jira] Commented: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Christian Sprecher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719312#action_12719312 ]
Christian Sprecher commented on SLING-1003:
-------------------------------------------
Hmm, one step further, but still not there, I think:
java.lang.ClassCastException: org.webcastellum.RequestWrapper cannot be cast to
org.apache.sling.api.SlingHttpServletRequest
at org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper.getSlingRequest(SlingHttpServletRequestWrapper.java:56)
at org.apache.sling.engine.impl.request.RequestData.unwrap(RequestData.java:317)
at org.apache.sling.engine.impl.request.RequestData.getRequestData(RequestData.java:401)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:496)
at org.apache.sling.engine.impl.SlingMainServlet.processRequest(SlingMainServlet.java:430)
at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:63)
at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54)
at org.webcastellum.WebCastellumFilter.internalDoFilter(WebCastellumFilter.java:2611)
at org.webcastellum.WebCastellumFilter.doFilter(WebCastellumFilter.java:1711)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54)
at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:317)
at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:192)
Hmm, kind of makes sense:
api.wrappers.SlingHttpServletRequestWrapper.SlingHttpServletRequest#getSlingRequest() always returns a SlingHttpServletRequest
org.apache.sling.engine.impl.request.RequestData#unwrap(
SlingHttpServletRequest request) {
while (request instanceof SlingHttpServletRequestWrapper) {
request = ((SlingHttpServletRequestWrapper) request).getSlingRequest();
}
if (request instanceof SlingHttpServletRequestImpl) {
return (SlingHttpServletRequestImpl) request;
}
throw new IllegalArgumentException(
"SlingHttpServletRequest not of correct type");
}
I.e. we are deep into Sling land here, already. I am unsure where to exactly do the difference ...
> 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.0.6
>
>
> 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.
[jira] Updated: (SLING-1003) Integration of 3rd party servlet
filters problematic
Posted by "Christian Sprecher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Christian Sprecher updated SLING-1003:
--------------------------------------
Attachment: RequestData.diff
Patch for RequestData#unwrap(SlingHttpServletRequest):
*foreign* ServletWrappers are allowed.
Please test it carefully! It runs both with and without the webcastellum filter, but I only tested it in standard configuration, i.e. no special filters enabled
> 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.0.6
>
> 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.