struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>
Subject Re: Struts seems to reset the action instance while its still in interceptor
Date Sun, 03 Nov 2013 22:16:26 GMT
can you provide the code of your action?


2013/11/3 Ali Akhtar <ali.rac200@gmail.com>

> One more thing, in my actual code, I am doing ai.invokeActionOnly(), rather
> than ai.invoke() .
>
>
> On Mon, Nov 4, 2013 at 2:49 AM, Ali Akhtar <ali.rac200@gmail.com> wrote:
>
> > Hopefully I am incorrect, however the following lines in my interceptor's
> > intercept method:
> >
> >      action =  ai.getAction();
> >     String result = ai.invoke();
> >     logger.debug("Orig action : " + action.toString()  +" , now : " +
> > ai.getAction().toString() );
> >
> > Do produce two different toString() codes for the original action and the
> > new ai.getAction(). Is there any scenario in which this could happen?
> >
> > I'm serving two actions from the same class, i.e mysite/foo is being
> > served by FooAction.foo(), and mysite/bar is being served by
> > FooAction.bar(). So in both cases, the same class is serving two actions.
> > Could this have any bearing on why action.toString() and
> > ai.getAction.toString() are producing different codes?
> >
> >
> > On Mon, Nov 4, 2013 at 2:18 AM, Dave Newton <davelnewton@gmail.com>
> wrote:
> >
> >> You are incorrect. Actions are instantiated per-request. Other than
> that,
> >> you will need to provide a working example that exhibits the incorrect
> >> behavior.
> >>  On Nov 3, 2013 12:57 PM, "Ali Akhtar" <ali.rac200@gmail.com> wrote:
> >>
> >> > Hello,
> >> >
> >> > It seems that if I have two concurrent requests being made to the same
> >> > action, e.g mysite.com/fooAction, then struts resets the first
> action's
> >> > instance while that instance may still be in the interceptor.
> >> >
> >> > E.g, if I have the following code in my interceptor:
> >> >
> >> >     action =  ai.getAction();
> >> >     String result = ai.invoke();
> >> >     logger.debug("Orig action : " + action.toString()  +" , now : " +
> >> > ai.getAction().toString() );
> >> >
> >> > And if I make two concurrent requests to the same action (e.g using
> >> > javascript), then the line:
> >> >
> >> >     logger.debug("Orig action : " + action.toString()  +" , now : " +
> >> > ai.getAction().toString() );
> >> >
> >> > will sometimes produce two different `toString()` codes, showing that
> >> the
> >> > original action was in a different instance than the last action.
> >> >
> >> > This is a big problem, because now, if I had any code in the
> >> interceptor,
> >> > which was setting certain things on my action, e.g doing the
> following:
> >> >
> >> >     MyAction action =  (MyAction) ai.getAction();
> >> >     Auth auth = new Auth ( action.getSession() );
> >> >     action.setAuth(auth);
> >> >     action.setCookiesMap( Util.getAllCookies() );
> >> >     String result = ai.invoke();
> >> >
> >> > then there is no guarantee that all those things which I've set on my
> >> > action are in fact going to be passed to the correct instance. I.e,
> when
> >> > `ai.invoke()` is called, it may in fact call a completely different
> >> > instance of the action, which has different cookies or other data set
> on
> >> > it. This could result in different users being given access to each
> >> other's
> >> > data.
> >> >
> >> > Am I correct in all of this? If so, is there a solution to this
> problem?
> >> > Because this seems to completely defeat the purpose of interceptors.
> >> >
> >> > Thanks in advance.
> >> >
> >>
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message