struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Diederen ...@ionicsoft.com>
Subject Action Framework: simultaneous requests on the same path, in the same session.
Date Wed, 18 Jan 2006 15:56:14 GMT

Hello,

[I've searched the web and the archives, but couldn't find anything 
useful (I'm not sure the terms of my queries were appropriate/efficient)]

My problem is this (I'm using struts 1.2.7):

When someone uses my webapp, some javascript sometimes triggers twice 
the same action in a very short amount of time (I mean: two POST 
requests are issued that call the same action's execute()) _with 
different parameters_.
I noticed that the action sometimes receives the same set of parameters 
twice. Further investigation confirms that the form is populated for the 
first time, then for the second time and that, only then, the execute() 
method is called twice. That is due to thread concurrency, I suppose.

In the RequestProcessor, I noticed there's no synchronization on the 
form, in the process() method, that ensures that the form is populated 
and then the action executed with the set of parameters it was supposed 
to receive.
I did a little modification in RequestProcessor (actually, I extended 
it) and came up with:

original code:
--------
        ActionForm form = processActionForm(request, response, mapping);
        processPopulate(request, response, form, mapping);
           ...
        // Call the Action instance itself
        ActionForward forward =
            processActionPerform(request, response,
                                 action, form, mapping);
--------


modified code:
--------
       ActionForm form = processActionForm(request, response, mapping);
       synchronized (form) {
            processPopulate(request, response, form, mapping);
               ...
            // Call the Action instance itself
            ActionForward forward =
                processActionPerform(request, response,
                                     action, form, mapping);
       }
--------

but I wonder if that's a good idea.
Am I missing something here? Is there a way to ensure that the action is 
called each time with the set of parameters it was supposed to receive?

Thank you for any information!

Best regards,
        Arnaud

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message