[ 
https://issues.apache.org/struts/browse/WW-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44162#action_44162
 ] 

Bob Tiernay commented on WW-2507:
---------------------------------

Today, I would think most session invalidation logic is as follows (as 
described in 
http://struts.apache.org/2.0.11.1/docs/how-do-we-get-invalidate-the-session.html):

        // Attempt to invalidate the session
        if (getSession() instanceof SessionMap) {
            try {
                ((SessionMap) getSession()).invalidate();
            } catch (IllegalStateException e) {
                log.error(e);
            }
        }    

Couldn't we doing something where the session invalidation is deferred? So 
instead of  ((SessionMap) getSession()).invalidate(), we have getSession() 
.invalidate()  which will defer invalidation until the end of the request, 
either by FilterDispatcher or by a ServletRequestListener.




> I18nInterceptor's intercept method is not thread safe
> -----------------------------------------------------
>
>                 Key: WW-2507
>                 URL: https://issues.apache.org/struts/browse/WW-2507
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.0.11
>            Reporter: Bob Tiernay
>             Fix For: 2.1.3
>
>
> The following excerpt from I18nInterceptor's intercept method is not thread 
> safe:
>         //save it in session
>         Map session = invocation.getInvocationContext().getSession(); <--- 
> start of atomic operation
>         if (session != null) {
>             if (requested_locale != null) {
>                 Locale locale = (requested_locale instanceof Locale) ?
>                         (Locale) requested_locale : 
> LocalizedTextUtil.localeFromString(requested_locale.toString(), null);
>                 if (log.isDebugEnabled()) {
>                     log.debug("store locale=" + locale);
>                 }
>                 if (locale != null) {
>                     session.put(attributeName, locale);
>                 }
>             }
>             //set locale for action
>             Object locale = session.get(attributeName); <--- session may no 
> longer exist due to concurrecy.
>             if (locale != null && locale instanceof Locale) {
>                 if (log.isDebugEnabled()) {
>                     log.debug("apply locale=" + locale);
>                 }
>                 saveLocale(invocation, (Locale)locale);
>             }
>         }
> Between the calls of:
> 1. Map session = invocation.getInvocationContext().getSession(); , and
> 2. Object locale = session.get(attributeName); 
> the session may have been invalidated.  In my particular application, this 
> was indeed the case.  This causes an invalid session exception to be raised.
> The recommended handling would be to synchronize this portion of the method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to