Skip to content

Conversation

@ravimergu1
Copy link

@ravimergu1 ravimergu1 commented Jul 23, 2025

Problem:

After adding a new feature to support Java 16 record-style properties (see this PR: #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 - [[1],"6Feet"]. 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
Issue2: #45 (comment)

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.

@patrickjamesbarry
Copy link

When will this change make it into a release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants