You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <ji...@apache.org> on 2006/07/08 17:30:29 UTC

[jira] Created: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

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

         Key: VELOCITY-449
         URL: http://issues.apache.org/jira/browse/VELOCITY-449
     Project: Velocity
        Type: Bug

    Versions: 1.5    
    Reporter: Henning Schmiedehausen
     Fix For: 1.5


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. 



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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


[jira] Closed: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-449.
-------------------------------------------


> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Nathan Bubna (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12432862 ] 
            
Nathan Bubna commented on VELOCITY-449:
---------------------------------------

get(key) is also part of the map interface.  yet we give it special syntactic treatment on all objects, map or not.  if a put(Object, Object) method exists, it is not meaningless.  it is meant to be used.  why force a different syntax for an identical method?

i really think that given our support of get() on any object; the burden of explanation is on the restriction to Map.

"treat like methods alike" seems like a better, simpler, and less surprising policy than "treat like methods alike unless they fail to declare that they implement a particular interface"  :)

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Alexey Panchenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12433016 ] 
            
Alexey Panchenko commented on VELOCITY-449:
-------------------------------------------

There should be two implementation clasess: one for objects implementing Map and another one using reflection for objects implementing just the method put(String,Object). The same for get(String).

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Henning Schmiedehausen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12440980 ] 
            
Henning Schmiedehausen commented on VELOCITY-449:
-------------------------------------------------

I hope I got you right, that you suggest to have additional executors that are smart about maps. I added code for that. If it was not what you meant, feel free to reopen that issue.

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12432848 ] 
            
Will Glass-Husain commented on VELOCITY-449:
--------------------------------------------

why?

"put" is part of the Map interface.  It makes sense to use it if the object is a map.

But otherwise, we follow (more or less) javabean semantics.  "put" has no meaning there.  If a POJO has a "put" object  we should ignore it, I think.

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Henning Schmiedehausen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12432879 ] 
            
Henning Schmiedehausen commented on VELOCITY-449:
-------------------------------------------------

There is an actual use case for that. I have a number of Turbine tools that offer

--- cut ---
public void get(String key) { ... }

public void getFoo() { }

public void getBar() { }

--- cut ---

Being able to write   $tool.Foo $tool.Bar $tool.Baz with the first two mapped to their explicit getters and the last one to get("Baz") is very useful. Having the same thing for setters makes it even more useful.


> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Resolved: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Henning Schmiedehausen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/VELOCITY-449?page=all ]

Henning Schmiedehausen resolved VELOCITY-449.
---------------------------------------------

    Resolution: Fixed

Patch will be in 1.5 release.

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Nathan Bubna (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12432615 ] 
            
Nathan Bubna commented on VELOCITY-449:
---------------------------------------

Agreed.  We should remove the test for Map assignability.  If  public Object put(Object, Object) is there, it should work whether or not it is a Map.

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VELOCITY-449) Velocity Uberspector behaves differently for get(String) and put(String, Object) methods

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-449?page=comments#action_12432863 ] 
            
Will Glass-Husain commented on VELOCITY-449:
--------------------------------------------

ah, forgot that get(string) is not a javabean semantic.

ok, makes sense.  in general, I agree that we should keep things easy for users rather than force rules on them.  I withdraw my objection.

> Velocity Uberspector behaves differently for get(String) and put(String, Object) methods
> ----------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-449
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-449
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Henning Schmiedehausen
>             Fix For: 1.5
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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