commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paritosh ranjan <paritoshranj...@gmail.com>
Subject WW-2736:Problem still present:Found Solution
Date Sun, 08 Mar 2009 11:26:59 GMT
I found http://issues.apache.org/struts/browse/WW-2736 in a particular
scenario.
I think the problem is not having any relation with the browser.

TokenSessionStoreInterceptor<javascript:searchRef('TokenSessionStoreInterceptor')>.java
has two methods:

protected <javascript:searchRef('TokenSessionStoreInterceptor')>String<javascript:searchRef('String')>
<javascript:searchRef('TokenSessionStoreInterceptor')>handleInvalidToken<javascript:searchRef('handleInvalidToken')>
( <javascript:searchRef('TokenSessionStoreInterceptor')>ActionInvocation<javascript:searchRef('ActionInvocation')>
<javascript:searchRef('TokenSessionStoreInterceptor')>invocation<javascript:searchRef('invocation')>)
throws <javascript:searchRef('TokenSessionStoreInterceptor')>Exception<javascript:searchRef('Exception')>
();
protected String <javascript:searchRef('String')>
handleValidToken<javascript:searchRef('handleValidToken')>
(ActionInvocation <javascript:searchRef('ActionInvocation')>
invocation<javascript:searchRef('invocation')>)
throws Exception <javascript:searchRef('Exception')>();

The <javascript:searchRef('handleInvalidToken')> scenario under which the
problem is reproduced occurred when the thread handling invalid request was
executed before the thread handling valid request.
So, to solve this issue, I applied the following fix:


 protected <javascript:searchRef('TokenSessionStoreInterceptor')>String<javascript:searchRef('String')>
<javascript:searchRef('TokenSessionStoreInterceptor')>handleInvalidToken<javascript:searchRef('handleInvalidToken')>
( <javascript:searchRef('TokenSessionStoreInterceptor')>ActionInvocation<javascript:searchRef('ActionInvocation')>
<javascript:searchRef('TokenSessionStoreInterceptor')>invocation<javascript:searchRef('invocation')>)
throws <javascript:searchRef('TokenSessionStoreInterceptor')>Exception<javascript:searchRef('Exception')>
(){
       synchronized(theHttpSessionObject){
          //wait is having time to avoid deadlocks i.e. the case when the
invalid request reaches after valid requests notification
          wait(3000);
        }
        //the rest of the code goes here
        ...
}
protected String <javascript:searchRef('String')>
handleValidToken<javascript:searchRef('handleValidToken')>
(ActionInvocation <javascript:searchRef('ActionInvocation')>
invocation<javascript:searchRef('invocation')>)
throws Exception <javascript:searchRef('Exception')>(){
       synchronized(theHttpSessionObject){

        String <javascript:searchRef('String')>
key<javascript:searchRef('key')>=
TokenHelper <javascript:searchRef('TokenHelper')>.getTokenName<javascript:searchRef('getTokenName')>
();
        String <javascript:searchRef('String')>
token<javascript:searchRef('token')>=
TokenHelper <javascript:searchRef('TokenHelper')>.getToken<javascript:searchRef('getToken')>
(key <javascript:searchRef('key')>);
        InvocationSessionStore<javascript:searchRef('InvocationSessionStore')>
.storeInvocation
<javascript:searchRef('storeInvocation')>(key<javascript:searchRef('key')>,
token <javascript:searchRef('token')>,
invocation<javascript:searchRef('invocation')>
);
        ...
        //Just notifiying before return
        notifyAll();
        return invocation
<javascript:searchRef('invocation')>.invoke<javascript:searchRef('invoke')>
();
        }
}



The problem is dependent on threads so the issue is reproduced sometimes in
mozilla , but in IE it got reproduced everytime(for me, as there are threads
involved, so the scenario is JVM dependent, when it will get reproduced
depends on the JVM thread sceduler, but the issue is present for sure).

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