David E Jones wrote:
> This is actually kind of annoying. The get(Object) method used to function 
> quite differently from get(String). IMO it was nice that get(String) used to 
> throw an exception (better immediate feedback for misspellings in code) while 
> get(Object) logged a message in order to follow the Map semantics.
> 
> It looks like the was "refactored" and "improved" at some point. I hope it 
> wasn't me...
> 
> -David

commit a0c5d5e6cc2ffa5fe603016a6382836fca3922ce
Author: lektran <lekt...@13f79535-47bb-0310-9956-ffa450edef68>
Date:   Tue Oct 6 14:07:04 2009 +0000

    Fix an inconsistency in GenericEntity's get methods when the key
doesn't exist, get(String) throws an exception but get(Object) just
logs a warning.  Changed so that both methods just log a warning.

    git-svn-id: https://svn.eu.apache.org/repos/asf/ofbiz/tr...@822276
13f79535-47bb-0310-9956-ffa450edef68

Scott, what was your reasoning behind this?

> On Mar 16, 2010, at 2:55 PM, Adam Heath wrote:
> 
>> GenericEntity.get(Object) does an immediate cast to String.  This is
>> *not allowed*.  The spec for java.util.Map says that *any* object can
>> be passed, and if it isn't contained in the map, to return null.  This
>> includes objects that don't match the generics signature(String in
>> this case).
>>
>> Related to this, get(String) has a Debug.logWarning call, that says
>> it's printing an IllegalArgumentException when an invalid field is
>> passed.  This isn't so; no such exception actually *is* printed.
>> Plus, the map contract allows for unknown fields to be looked up,
>> without an error.
>>
>> Related to this latter problem, is that remove() and containsKey()
>> don't do this unknown field warning.
>>
>> I found these two problems, because I noticed the warning message in
>> my log, and wanted to fix my code, but then discovered that there
>> isn't really an exception.
> 

Reply via email to