struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Evgrafov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (WW-3603) XWorkMapPropertyAccessor always create new map entries
Date Mon, 11 Apr 2011 11:25:05 GMT
XWorkMapPropertyAccessor always create new map entries
------------------------------------------------------

                 Key: WW-3603
                 URL: https://issues.apache.org/jira/browse/WW-3603
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.2.1
            Reporter: Igor Evgrafov


{{XWorkMapPropertyAccessor}} uses {{context.get(ReflectionContextState.CREATE_NULL_OBJECTS)
!= null}} to check if it in create new objects mode.
{code}
            if (result == null &&
                    context.get(ReflectionContextState.CREATE_NULL_OBJECTS) != null //BUG
                    &&  objectTypeDeterminer.shouldCreateIfNew(lastClass,lastProperty,target,null,false))
{
                Class valueClass = objectTypeDeterminer.getElementClass(lastClass, lastProperty,
key);

                try {
                    result = objectFactory.buildBean(valueClass, context);
                    map.put(key, result);
                } catch (Exception exc) {

                }

            }
{code}

However {{ParametersInterceptor}} uses {{ReflectionContextState.setCreatingNullObjects(contextMap,
true\false);}} to turn this mode on and off. In result {{context.get(ReflectionContextState.CREATE_NULL_OBJECTS)
!= null}} is always true.

{code:title=com.opensymphony.xwork2.interceptor.ParametersInterceptor}
                Map<String, Object> contextMap = ac.getContextMap();
                try {
                    ReflectionContextState.setCreatingNullObjects(contextMap, true);
                    ReflectionContextState.setDenyMethodExecution(contextMap, true);
                    ReflectionContextState.setReportingConversionErrors(contextMap, true);

                    ValueStack stack = ac.getValueStack();
                    setParameters(action, stack, parameters);
                } finally {
                    ReflectionContextState.setCreatingNullObjects(contextMap, false);
                    ReflectionContextState.setDenyMethodExecution(contextMap, false);
                    ReflectionContextState.setReportingConversionErrors(contextMap, false);
                }
{code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message