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


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