public void testNullIsNotReturnedWhenCreateNullObjectsIsSpecified() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.emptyMap())); ReflectionContextState.setCreatingNullObjects(vs.getContext(), true); Object value = vs.findValue("map['key']"); assertNotNull(value); assertSame(Object.class, value.getClass()); }
public void testNullIsReturnedWhenCreateNullObjectsIsSpecifiedAsFalse() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.emptyMap())); ReflectionContextState.setCreatingNullObjects(vs.getContext(), false); assertNull(vs.findValue("map['key']")); }
ReflectionContextState.setCreatingNullObjects(context, true); ReflectionContextState.setDenyMethodExecution(context, true); ReflectionContextState.setReportingConversionErrors(context, true);
Map<String, Object> contextMap = ac.getContextMap(); try { ReflectionContextState.setCreatingNullObjects(contextMap, true); ReflectionContextState.setReportingConversionErrors(contextMap, true); final ValueStack stack = ac.getValueStack(); ReflectionContextState.setCreatingNullObjects(context, true); ReflectionContextState.setDenyMethodExecution(context, true); ReflectionContextState.setReportingConversionErrors(context, true); addParametersToContext(ac, parameters); } finally { ReflectionContextState.setCreatingNullObjects(contextMap, false); ReflectionContextState.setReportingConversionErrors(contextMap, false);
ReflectionContextState.setCreatingNullObjects(context, true); ReflectionContextState.setDenyMethodExecution(context, true); ReflectionContextState.setReportingConversionErrors(context, true);
@Override public String doIntercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (!(action instanceof NoParameters)) { ActionContext ac = invocation.getInvocationContext(); final Map<String, Object> parameters = retrieveParameters(ac); if (LOG.isDebugEnabled()) { LOG.debug("Setting params " + getParameterLogMap(parameters)); } if (parameters != null) { 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); } } } return invocation.invoke(); }