Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-806

Can't access map values when get(Object key) is overriden

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Cannot Reproduce
    • 1.7
    • None
    • Engine
    • None

    Description

      I try to add a java.util.Map instance to Velocity context and access its values from a template, for example: ${map.get("someKey")}
      It doesn't work if use my own implementation of Map.get(Object key). It doesn't matter whether I implement Map from scratch, or subclass HashMap and override the get(Object key) metho. The get method is never called and the engine output is: ${map.get("someKey")}.

      It does work if I use my own subclass of HashMap without overriding the get(Object key) method.
      It does work if I use my own implementation of Map with the get(String key) method added: the get(String key) is called instead of get(Object key).
      It does work if I use my class that doesn't implement Map, but has a get(Object key) method.

      More discussion of this on Velocity-User mailing list: http://old.nabble.com/Can%27t-acces-map-values-when-get%28%29-is-overriden-td31955214.html

      Attachments

        Activity

          People

            cbrisson Claude Brisson
            mmatela Mateusz Matela
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: