You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Duffy Gillman (JIRA)" <my...@incubator.apache.org> on 2005/07/08 20:08:11 UTC
[jira] Created: (MYFACES-315) EL returns null for any Map entry keyed by an empty String
EL returns null for any Map entry keyed by an empty String
----------------------------------------------------------
Key: MYFACES-315
URL: http://issues.apache.org/jira/browse/MYFACES-315
Project: MyFaces
Type: Bug
Versions: 1.0.9 beta
Environment: Java 1.4.x, Tomcat 5.x
Reporter: Duffy Gillman
Priority: Critical
The expression language is coded to return null for any Map access using and empty String ("") as a key. Without a great deal of knowledge about the code behind the EL, I was able to find this:
(source: org/apache/myfaces/el/PropertyResolverImpl.java)
public Object getValue(Object base, Object property)
throws EvaluationException, PropertyNotFoundException
{
try
{
if (base == null || property == null ||
property instanceof String && ((String)property).length() == 0)
{
return null;
}
if (base instanceof Map)
{
return ((Map) base).get(property);
}
// If none of the special bean types, then process as normal Bean
return getProperty(base, property.toString());
}
The initial conditional makes it impossible to pass an empty String to a Map, even though this is not a violation of the Map contract. A potential solution is:
if (base == null || property == null ||
(property instanceof String && ((String)property).length() == 0 &&
!(base instanceof Map)))
{
return null;
}
if (base instanceof Map)
{
return ((Map) base).get(property);
}
Breaking out the if-conditional into smaller chunks may be more readable.
--
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
[jira] Closed: (MYFACES-315) EL returns null for any Map entry keyed by an empty String
Posted by "Martin Marinschek (JIRA)" <my...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-315?page=all ]
Martin Marinschek closed MYFACES-315:
-------------------------------------
Fix Version: Nightly Build
Resolution: Fixed
Thanks to Duffy Gillman for this fix.
> EL returns null for any Map entry keyed by an empty String
> ----------------------------------------------------------
>
> Key: MYFACES-315
> URL: http://issues.apache.org/jira/browse/MYFACES-315
> Project: MyFaces
> Type: Bug
> Versions: 1.0.9 beta
> Environment: Java 1.4.x, Tomcat 5.x
> Reporter: Duffy Gillman
> Assignee: Martin Marinschek
> Priority: Critical
> Fix For: Nightly Build
>
> The expression language is coded to return null for any Map access using and empty String ("") as a key. Without a great deal of knowledge about the code behind the EL, I was able to find this:
> (source: org/apache/myfaces/el/PropertyResolverImpl.java)
> public Object getValue(Object base, Object property)
> throws EvaluationException, PropertyNotFoundException
> {
> try
> {
> if (base == null || property == null ||
> property instanceof String && ((String)property).length() == 0)
> {
> return null;
> }
> if (base instanceof Map)
> {
> return ((Map) base).get(property);
> }
>
> // If none of the special bean types, then process as normal Bean
> return getProperty(base, property.toString());
> }
> The initial conditional makes it impossible to pass an empty String to a Map, even though this is not a violation of the Map contract. A potential solution is:
> if (base == null || property == null ||
> (property instanceof String && ((String)property).length() == 0 &&
> !(base instanceof Map)))
> {
> return null;
> }
> if (base instanceof Map)
> {
> return ((Map) base).get(property);
> }
> Breaking out the if-conditional into smaller chunks may be more readable.
--
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