Struts 2
  1. Struts 2
  2. WW-3603

XWorkMapPropertyAccessor always create new map entries

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.3.16
    • Component/s: None
    • Labels:
      None

      Description

      XWorkMapPropertyAccessor uses "context.get(ReflectionContextState.CREATE_NULL_OBJECTS) != null" to check if it in create new objects mode.

                  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) {
      
                      }
      
                  }
      

      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 and result bean is always created.

                      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);
                      }
      

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Igor Evgrafov
          • Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development