Description
I think it is caused by the refactor of WW-5333
When the tag "set" is used to define a variable whose name is of length 1, a java.lang.ClassCastException (class java.lang.Character cannot be cast to class java.lang.String ) is thrown.
Test case:
// code placeholder <s:set var="a" value="1" /> a = <s:property value="a"/> <s:set var="b" value="2" scope="page" /> b = <s:property value="b" />
Expected result:
// code placeholder
a = 1
b = 2
actual result:
a = 1 b =
Both "s:set" throws exception when storing the value in page context. Value of a is retrieved as it is successfully saved in default context
Exception trace
// code placeholder Error setting value [2] with expression [#attr['b']] java.lang.ClassCastException: class java.lang.Character cannot be cast to class java.lang.String (java.lang.Character and java.lang.String are in module java.base of loader 'bootstrap') at org.apache.struts2.dispatcher.AttributeMap.put(AttributeMap.java:46) ~[struts2-core-6.4.0.jar:6.4.0] at com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor.setProperty(XWorkMapPropertyAccessor.java:130) ~[struts2-core-6.4.0.jar:6.4.0] at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:3359) ~[ognl-3.3.4.jar:?] at ognl.ASTProperty.setValueBody(ASTProperty.java:134) ~[ognl-3.3.4.jar:?] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) ~[ognl-3.3.4.jar:?] at ognl.SimpleNode.setValue(SimpleNode.java:308) ~[ognl-3.3.4.jar:?] at ognl.ASTChain.setValueBody(ASTChain.java:227) ~[ognl-3.3.4.jar:?] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) ~[ognl-3.3.4.jar:?] at ognl.SimpleNode.setValue(SimpleNode.java:308) ~[ognl-3.3.4.jar:?] at ognl.Ognl.setValue(Ognl.java:829) ~[ognl-3.3.4.jar:?] at com.opensymphony.xwork2.ognl.OgnlUtil.ognlSet(OgnlUtil.java:585) ~[struts2-core-6.4.0.jar:6.4.0] at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:522) ~[struts2-core-6.4.0.jar:6.4.0] at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:258) [struts2-core-6.4.0.jar:6.4.0] at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:245) [struts2-core-6.4.0.jar:6.4.0] at org.apache.struts2.components.Set.end(Set.java:113) [struts2-core-6.4.0.jar:6.4.0] at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:38) [struts2-core-6.4.0.jar:6.4.0]
When name is of length 1, the key is created as Character not String, and it fails when trying to store in a
AttributeMap extends AbstractMap<String, Object>
Attachments
Issue Links
- links to