[PR] [VELOCITY-986] Fixed issues when the map has its meth ods as keys like size and values [velocity-engine]

ravimergu1 (via GitHub) <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <[email protected]>
ravimergu1 opened a new pull request, #59:
URL: https://github.com/apache/velocity-engine/pull/59

   **Problem:**
   
   After adding a new feature to support Java 16 record-style properties (see this PR: https://github.com/apache/velocity-engine/pull/45), we are seeing an issue when using a Map that has keys with the same names as method names.
   
   Here is an example:
   
   ```
   Map<String, Object> map = new HashMap<>();
   List<Integer> list = new ArrayList<>();
   list.add(1);
   map.put("values", list);
   map.put("size", "6Feet");
   ```
   
   In this example:
   
   1.  When we try to get values, we expect to get the list [1], but instead we get all values from the map. This happens because it's calling the map.values() method, not the "values" key.
   2.  When we try to get size, we expect to get "6Feet", but we get 2 instead, because it's calling the map.size() method.
   
   **Reported issues:** 
   
   Issue1: [VELOCITY-986](https://issues.apache.org/jira/browse/VELOCITY-986)
   Issue2: https://github.com/apache/velocity-engine/pull/45#discussion_r2225914086
   
   **Solution:**
   
   To fix this, we should skip or ignore Map objects when using the Java 16 record-style property feature. That way, it will get the actual values from the map keys, not from the methods.
   


-- 
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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.