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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to