[ 
https://issues.apache.org/jira/browse/WW-5536?focusedWorklogId=1002173&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1002173
 ]

ASF GitHub Bot logged work on WW-5536:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Jan/26 08:01
            Start Date: 28/Jan/26 08:01
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart commented on code in PR #1405:
URL: https://github.com/apache/struts/pull/1405#discussion_r2735333025


##########
core/src/main/java/org/apache/struts2/ognl/accessor/XWorkMethodAccessor.java:
##########
@@ -41,40 +40,40 @@
  */
 public class XWorkMethodAccessor extends ObjectMethodAccessor {
 
-       private static final Logger LOG = 
LogManager.getLogger(XWorkMethodAccessor.class);
+    private static final Logger LOG = 
LogManager.getLogger(XWorkMethodAccessor.class);
 
     @Override
-    public Object callMethod(Map context, Object object, String string, 
Object[] objects) throws MethodFailedException {
+    public Object callMethod(OgnlContext context, Object object, String 
string, Object[] objects) throws MethodFailedException {
 
         //Collection property accessing
         //this if statement ensures that ognl
         //statements of the form someBean.mySet('keyPropVal')
         //return the set element with value of the keyProp given
 
-        if (objects.length == 1 && context instanceof OgnlContext) {
+        if (objects.length == 1) {
             try {
-              OgnlContext ogContext=(OgnlContext)context;
-              if (OgnlRuntime.hasSetProperty(ogContext, object, string))  {
-                       PropertyDescriptor 
descriptor=OgnlRuntime.getPropertyDescriptor(object.getClass(), string);
-                       Class propertyType=descriptor.getPropertyType();
-                       if ((Collection.class).isAssignableFrom(propertyType)) {
-                           //go directly through OgnlRuntime here
-                           //so that property strings are not cleared
-                           //i.e. OgnlUtil should be used initially, 
OgnlRuntime
-                           //thereafter
+                OgnlContext ogContext = context;

Review Comment:
   fixed



##########
core/src/main/java/org/apache/struts2/ognl/OgnlUtil.java:
##########
@@ -198,13 +197,32 @@ public void clearBeanInfoCache() {
      * Check the size of the BeanInfo cache (current number of elements).
      *
      * @return current number of elements in the BeanInfo cache.
-     *
      * @since 2.5.21
      */
     public int beanInfoCacheSize() {
         return beanInfoCache.size();
     }
 
+    /**
+     * Ensures that the given context is an OgnlContext. If it's already an 
OgnlContext, returns it as-is.
+     * If it's a plain Map (like HashMap), wraps it in an OgnlContext to 
ensure compatibility with OGNL 3.4.8+.
+     *
+     * @param context the context map that may or may not be an OgnlContext
+     * @return an OgnlContext instance
+     * @since 7.2.0
+     */
+    private OgnlContext ensureOgnlContext(Map<String, Object> context) {
+        if (context instanceof OgnlContext ognlContext) {
+            return ognlContext;
+        }
+        // Create a new OgnlContext and copy the Map contents
+        OgnlContext ognlContext = createDefaultContext(null);
+        if (context != null) {

Review Comment:
   removed





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1002173)
    Time Spent: 3.5h  (was: 3h 20m)

> Bump ognl:ognl from 3.3.5 to 3.4.8
> ----------------------------------
>
>                 Key: WW-5536
>                 URL: https://issues.apache.org/jira/browse/WW-5536
>             Project: Struts 2
>          Issue Type: Dependency
>          Components: Core
>    Affects Versions: 6.7.0, 7.0.0
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.2.0
>
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to