[ 
https://issues.apache.org/struts/browse/WW-2101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42791
 ] 

Aleksander Adamowski commented on WW-2101:
------------------------------------------

Don't you think that removing Preparator and ServletContextHolderListener 
without even noting it in release notes 
(http://struts.apache.org/2.0.11/docs/release-notes-2010.html, 
http://struts.apache.org/2.0.11/docs/release-notes-2011.html) is a bit 
irresponsible?

The Maven archtypes which provide example projects (e.g. 
struts2-archetype-portlet) contain references to those classes in web.xml and 
they get broken when updating struts2-core JAR to 2.0.10 or 2.0.11.

The example web.xml contains this:

    <listener>
                <listener-class>
                        
org.apache.struts2.portlet.context.ServletContextHolderListener
                </listener-class>
        </listener>

        <servlet id="preparator">
                <servlet-name>preparator</servlet-name>
                <servlet-class>
                        org.apache.struts2.portlet.context.PreparatorServlet
                </servlet-class>
        </servlet>


What to do in 2.0.10 an later? Simply remove the listener and preparator? Won't 
something break in a mysterious way?


> PreparatorServlet causes request and response objects to be used outside of 
> service() method
> --------------------------------------------------------------------------------------------
>
>                 Key: WW-2101
>                 URL: https://issues.apache.org/struts/browse/WW-2101
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Portlet
>            Reporter: Rickard Öberg
>            Assignee: Nils-Helge Garli
>            Priority: Critical
>             Fix For: 2.0.10, 2.1.0
>
>
> The PreparatorServlet stores the request and response object to be used 
> later. The servlet spec (SRV.2.3.3.3) states the following:
> "References to the request and response objects should not be given to objects
> executing in other threads as the resulting behavior may be nondeterministic. 
> If
> the thread created by the application uses the container-managed objects, 
> such as
> the request or response object, those objects must be accessed only within the
> servlet's service life cycle and such thread itself should have a life cycle 
> within
> the life cycle of the servlet's service method because accessing those objects
> after the service method ends may cause undeterministic problems."
> So, it is not legal to store those objects as there is no way to know that 
> the objects are valid after the service() invocation. And indeed, in our 
> portal container implementation those object are immediately invalidated 
> after the service() method, causing deterministically problematic situations 
> for our users that has chosen Struts 2.
> I understand that the whole idea of using PreparatorServlet is to get a 
> reference to ServletRequest and ServletResponse objects, but it is not a 
> valid way to do it. It would probably be better if it was possible to simple 
> implement wrapper objects that work with the PortletRequest and 
> PortletResponse objects instead, in the portlets render() method.

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

Reply via email to