[
https://issues.apache.org/jira/browse/WW-5424?focusedWorklogId=921640&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-921640
]
ASF GitHub Bot logged work on WW-5424:
--------------------------------------
Author: ASF GitHub Bot
Created on: 02/Jun/24 12:00
Start Date: 02/Jun/24 12:00
Worklog Time Spent: 10m
Work Description: sonarcloud[bot] commented on PR #946:
URL: https://github.com/apache/struts/pull/946#issuecomment-2143819643
## [](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=946)
**Quality Gate passed**
Issues
 [0 New
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=946&resolved=false&sinceLeakPeriod=true)
 [0 Accepted
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=946&resolutions=WONTFIX)
Measures
 [0 Security
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=946&resolved=false&sinceLeakPeriod=true)
 [100.0% Coverage on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=946&metric=new_coverage&view=list)
 [0.0% Duplication on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=946&metric=new_duplicated_lines_density&view=list)
[See analysis details on
SonarCloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=946)
Issue Time Tracking
-------------------
Worklog Id: (was: 921640)
Time Spent: 20m (was: 10m)
> ClassCastException with tag "set" when variable name has length=1
> -----------------------------------------------------------------
>
> Key: WW-5424
> URL: https://issues.apache.org/jira/browse/WW-5424
> Project: Struts 2
> Issue Type: Bug
> Components: Core Tags
> Affects Versions: 6.4.0
> Reporter: Daniel López
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 6.5.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> 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:java}
> // 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" />{code}
> Expected result:
> {code:java}
> // code placeholder
> a = 1
> b = 2{code}
> actual result:
> {code:java}
> a = 1
> b ={code}
> 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:java}
> // 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]
> {code}
> 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>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)