struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbert Hirneisen" <>
Subject Struts 1 and thread safety
Date Fri, 17 Sep 2010 09:00:42 GMT

I have al large Struts 1 application with a modified DispatchAction class. Most
action classes are derivatives from this class.
In the webapp I have several projects defined. The project can be determined by
analysing the URL.
This is done in the central DispatchAction-class by using class fields declared
as volatile. The execute-Method is declared as synchronized.
After reading a lot about thread safety now I´m not sure if this approach is
thread safe on a request level.
Abbreviated example:

public abstract class DispatchAction extends Action {
protected volatile long projectId = -1;

synchronized public ActionForward execute(
 ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
 throws Exception {
   long projectId = Project.getIdFromRequest(request);
 return forward;

When I access projectId from a derived class is this thread safe or have I to
implement in the doExecute-Method of each derived action class ? This would be
thread safe but comes with a lot of redundant code.

Any help would be helpful.

Best regards,

Norbert Hirneisen

science4you Online-Monitoring

Die Falternacht:
Werden Sie Falterzähler:
Tagfalter-Monitoring Deutschland:
Infos über geschützte Arten ?

Norbert Hirneisen
Science & Communications

von-Müllenark-Str. 19
53179 Bonn
Tel. 0228/6194930
Ust.ID-Nr. DE237150377

Der Inhalt dieser Mitteilung ist nur für obigen Adressaten bestimmt und streng
vertraulich. Eine Weitergabe oder Vervielfältigung durch andere als den
Adressaten ist verboten! Sollten Sie diese Nachricht irrtümlich erhalten haben,
ersuchen wir Sie um sofortige Verständigung und darum, sämtliche Dateien von
Ihrem Computer zu löschen. Unsere E-Mail sind geprüft, erfolgen jedoch ohne

The information contained in this message is intended only for the adressee. It
is strictly confidential. Any distribution, copying or disclosure by anyone but
the adressee is prohibited. In case you have received this message in error,
please notify us immediately and delete it form your system. Any liability for
information send via email of  us is excluded.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message