1. opensymphony
  2. xwork

Commits

musachy  committed 02c2100

XW-612 StaticParametersInterceptor does not obey CreateIfNull attribute

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1895e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits bc4606e
  • Branches master

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java

View file
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
 
         if (parameters != null) {
             ActionContext ac = ActionContext.getContext();
-            final ValueStack stack = ac.getValueStack();
-
-            for (Map.Entry<String, String> entry : parameters.entrySet()) {
-                Object val = entry.getValue();
-                if (parse && val instanceof String) {
-                    val = TextParseUtil.translateVariables(val.toString(), stack);
-                }
-                try {
-                    stack.setValue(entry.getKey(), val);
-                } catch (RuntimeException e) {
-                    if (devMode) {
-                        String developerNotification = LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
-                                "Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
-                        });
-                        LOG.error(developerNotification);
-                        if (action instanceof ValidationAware) {
-                            ((ValidationAware) action).addActionMessage(developerNotification);
+            Map<String, Object> contextMap = ac.getContextMap();
+            try {
+                ReflectionContextState.setCreatingNullObjects(contextMap, true);
+                ReflectionContextState.setReportingConversionErrors(contextMap, true);
+                final ValueStack stack = ac.getValueStack();
+
+                for (Map.Entry<String, String> entry : parameters.entrySet()) {
+                    Object val = entry.getValue();
+                    if (parse && val instanceof String) {
+                        val = TextParseUtil.translateVariables(val.toString(), stack);
+                    }
+                    try {
+                        stack.setValue(entry.getKey(), val);
+                    } catch (RuntimeException e) {
+                        if (devMode) {
+                            String developerNotification = LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
+                                    "Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
+                            });
+                            LOG.error(developerNotification);
+                            if (action instanceof ValidationAware) {
+                                ((ValidationAware) action).addActionMessage(developerNotification);
+                            }
                         }
                     }
                 }
+                addParametersToContext(ac, parameters);
+            } finally {
+                ReflectionContextState.setCreatingNullObjects(contextMap, false);
+                ReflectionContextState.setReportingConversionErrors(contextMap, false);
             }
-            addParametersToContext(ac, parameters);
         }
         return invocation.invoke();
     }