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

Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5
    • 1.5
    • None
    • None

    Description

      Consider an Object

      public class Test {
      private Object foo;

      public Object get(String dummy)

      { return foo; }

      public void put(String dummy, Object foo)

      { this.foo = foo }

      ;
      }

      Put this object into a Velocity Context as $test, add a HashMap as $map.

      Use the following template:

      $map.put("key", "val1")
      $test.put("key", "val1")

      $map.get("key") --> Returns val1
      $test.get("key") --> Returns val1

      $map.key --> Returns val1
      $test.key --> Returns val1

      #set ($map.key = "val2")
      #set ($test.key = "val2")

      $map.key --> Returns val2
      $test.key --> Returns val1 !!

      The reason for this is, that the UberspectorImpl, in getPropertySet tests in line 247 whether the passed object is assignable to a Map. This test is no in the getPropertyGet
      and seems to have no reason because the following method lookup for "put" will succeed anyway.

      I'd suggest the removal of this test.

      Attachments

        Activity

          People

            Unassigned Unassigned
            henning Henning Schmiedehausen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: