[ 
https://issues.apache.org/struts/browse/WW-1803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ted Husted resolved WW-1803.
----------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.0

Completed: At revision: 520151, 520152   

> ScopeIntercaptor null references on session serialization
> ---------------------------------------------------------
>
>                 Key: WW-1803
>                 URL: https://issues.apache.org/struts/browse/WW-1803
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Interceptors
>    Affects Versions: 2.0.6
>         Environment: Windows 2000. J2re1.4.2. Tomcat 5.5.20.
>            Reporter: Sylvain RIBEYRON
>             Fix For: 2.0.7, 2.1.0
>
>
> ScopeInterceptor uses a NULL object to store null values in session scope.
> When restarting tomcat, sessions are serialized on hard drive, and they are 
> reloaded. NULL object is also serialized. But as struts2 application starts, 
> when ScopeInterceptor class is loaded, it creates a new static field "NULL" 
> that is not the same reference as the serialised one.
> As a result, when test "o==NULL" is performed in method nullConvert, it 
> return false, whereas it should return true. Then, fields in action that 
> should remain to "null" value, are initialized with a "NULL" string !
> To resolve this issue, introduce a new NULLClass, and check if object o 
> extends this class, instead of testing reference equality. Use the following 
> code as a replacement:
>       private static class NULLClass implements Serializable {
>               public String toString() {
>                       return "NULL";
>               }
>               public boolean equals(Object obj) {
>                       return obj == null || (obj instanceof NULLClass);
>               }
>       }
>     private static final Object NULL = new NULLClass();
>     private static final Object nullConvert(Object o) {
>         if (o == null) {
>             return NULL;
>         }
>         if (o == NULL || NULL.equals(o)) {
>             return null;
>         }
>         return o;
>     }
> Struts 2 is a great job ! Thanks.

-- 
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