ravimergu1 commented on code in PR #45:
URL: https://github.com/apache/velocity-engine/pull/45#discussion_r2225914086


##########
velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java:
##########
@@ -119,6 +119,16 @@ protected void discover(final Class<?> clazz, final String 
property)
 
                 setMethod(introspector.getMethod(clazz, sb.toString(), 
params));
             }
+
+            if (!isAlive())
+            {
+                /*
+                 * If no JavaBean property was found, try the convention used 
by Java 16 records.
+                 * No convenience case flip because the more convenient 
lowerCamelCase is also the
+                 * more likely to be used in the record itself.
+                 */
+                setMethod(introspector.getMethod(clazz, property, params));
+            }

Review Comment:
   The sample application to replicate the issue. we are upgraded library from 
2.3 to 2.4.1
    
   ```
   import com.fasterxml.jackson.core.JsonProcessingException;
   import com.fasterxml.jackson.databind.ObjectMapper;
   import org.apache.velocity.VelocityContext;
   import org.apache.velocity.app.VelocityEngine;
   import org.apache.velocity.runtime.VelocityEngineVersion;
   
   import java.io.StringWriter;
   import java.util.Map;
   
   public class TestVelocity {
       public static final String studentData = "{ \"student\": { \"values\": [ 
" +
               "{ \"id\": 1, \"name\": \"Alice\", \"age\": 20, \"grade\": \"A\" 
}, " +
               "{ \"id\": 2, \"name\": \"Bob\", \"age\": 21, \"grade\": \"B\" } 
] } }";
       public static final String editorContent = "{\n" +
               "    \"students\" :  $student.values\n" +
               "}\n";
       public static final String LOG_LABEL = "TemplateParser";
       public static void main(String[] args) throws JsonProcessingException {
           VelocityEngine velocityEngine = new VelocityEngine();
           StringWriter writer = new StringWriter();
           Map studentsMap = new ObjectMapper().readValue(studentData, 
Map.class);
           VelocityContext context = new VelocityContext(studentsMap);
           velocityEngine.init();
           velocityEngine.evaluate(context,writer,LOG_LABEL,editorContent);
           System.out.println("Velocity Version: " + 
VelocityEngineVersion.VERSION);
           System.out.println(writer.toString());
       }
   }
   ```
   
   Before this Chage the output in (V2.3): Array have one square bracket [ ]
   ```
   Velocity Version: 2.3
   {
       "students" :  [{id=1, name=Alice, age=20, grade=A}, {id=2, name=Bob,
   age=21, grade=B}]
   }
   ```
   After this change the output in (V2.4.1): Array have two square bracket [[ ]]
   ```
   Velocity Version: 2.4.1
   {
       "students" :  [[{id=1, name=Alice, age=20, grade=A}, {id=2, name=Bob,
   age=21, grade=B}]]
   }
   ```
   
   After this PR changes we are seeing this deference, in 
**UberspectImpl.getPropertyGet()** method the
   **executor** value is **PropertyExecutor** instead of **MapGetExecutor**. 
Because of the output is changed



-- 
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: dev-unsubscr...@velocity.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to