It acctually might be pretty easy to test it base on your flow below.
 
lets make a helper class following the singlton pattern
 
give it a private volatile int myPhase=0;
 
now define a method 
 
void wait(int phase)
{
 while (myPhase<phase) 
 {
  Thread.yield();
  logger.log(Level.INFO, "Yielding becasue myPhase={0} and we are waiting on
phase {1}", new Object[]{myPhase,phase});
 }
 ++phase;
}
 
 
now psrinkle your waits around the code
 
wait(0);
 
 
wait(1);
 
 
wait (2); 
 
 
...
 
now that you can gate the code exactly as you want, does the problem occur?
 
Sorry, I do not anticipate the time to test your issue very soon, but I will
assist you in working it.
 
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us
<http://www.pdinc.us/>  -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.

 


  _____  

From: huang.mi...@gmail.com [mailto:huang.mi...@gmail.com] 
Sent: Sunday, May 22, 2011 14:02
To: Struts Developers List
Subject: RE: Portlet plugin renderDirect location transfer via session may has
concurrent issue


Hi Pyerson,
  I'm also using portlet2 plugin, which seems derived from struts portlet
plugin, brings same method to handle directRender from action phase. Thus it has
same problems :). But since the source is from struts bundled portlet plugin,
I'd better discuss this issue here.
  First let me clear the ACTION word. It's both used in struts and portlet
specification, referencing totally different things. I'll use "portlet action
phase" and "struts action" here to avoid confusing, although it's cumbersome.
  First some background information about this issue:
  A portlet action phase request is mapped to a struts action request by the
struts portlet plugin. Due to the portlet JSR definition, in action phase
process no output is rendered. Instead a follow on render phase request is used
to take the actual render responsible. However the struts action can define a
JSP render result. In this case, the struts action's result process actually not
do render process, but save the render JSP location to the session map and
finished the result process immediately. The actual JSP render process is taken
place by the follow on portlet render phase request, which is mapping to the
struts portlet plugin internal defined "directRender" action. The directRender
action load the previously saved JSP location and do the actual JSP render as
it's result. Thus the portlet render phase response get JSP render output AS IF
it is rendered out by the result defined in the struts action. See the in
question source code  which is doing the process described here:
    org.apache.struts2.portlet.result.PortletResult.executeActionResult(String,
ActionInvocation)
    org.apache.struts2.portlet.dispatcher.DirectRenderFromEventAction,

  The problem is:
  The session is shared by all requests in the same session, in a multi-threaded
concurrent executing environment. This may cause indeterminable problems on a
heavy load site.
  Suppose 2 request(Request A and Request B) from same session come to the
portal at nearly same time. The process sequence of the 2 request may like this:
  1. Request A get action phase process, and its struts action (action A) result
process stored  the JSP location (a.jsp) to the session map.
  2. Request B get action phase process, and its struts action (action B) result
process stored the JSP location (b.jsp) to the session map, which overwrites JSP
location (a.jsp) set by action A.
  3. Request A get render phase process, and the renderDirect action get
incorrect JSP location b.jsp. Request A will render the wrong JSP result.
  4. Request B get render phase process, and the renderDirect action get correct
JSP location b.jsp, and render the JSP result correctly.
  This problem may not easy to reproduce during the development lifecycle,
except you use an automatic load testing tool to test it. But when the system is
deployed to the production environment and the site load get heavy, the
possibility to run into the issue case get higher.
  Hope I have described the issue clearly and feel free to place a note on what
I have missing.

Best Regards,
Miles.


在 2011-05-21Sat的 20:54 -0400,Jason Pyeron写道: 

I am having a little trouble following what you are saying. Do you have an

example that might better say the issue.

 

I am currently using the portlet2 plugin as well.



________________________________



        From: Miles Huang [mailto:miles.hu...@surwing.com] 

        Sent: Saturday, May 21, 2011 11:52

        To: dev@struts.apache.org

        Subject: Portlet plugin renderDirect location transfer via session may

has concurrent issue

        

        

        Hi,

          I'm using struts2 portlet plugin for a portlet project recently.

          In some case, I have to use renderDirect action to render JSP result

directly from an portlet action phase request.

          When I'm examining the PortletResult source code, surprisingly I found

the result location is transfer to the renderDirect action via session map

instead of render parameter.

          Is there any special reason to do this? I think current via session

method may result current issue: Suppose multiple client in same session

(normally multiple opened browser windows) send action phase request to the

portlet concurrently, the result location of a action phase request may override

by another request.

          Any one can confirm on this?

        

        Thanks,

        Miles. 



--

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-                                                               -

- Jason Pyeron                      PD Inc. http://www.pdinc.us -

- Principal Consultant              10 West 24th Street #100    -

- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -

-                                                               -

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This message is copyright PD Inc, subject to license 20080407P00.







---------------------------------------------------------------------

To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org

For additional commands, e-mail: dev-h...@struts.apache.org




Reply via email to