tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Why AstValue (part of EL) coerces set value to the target type
Date Sun, 08 May 2011 23:50:09 GMT
2011/5/7 Fedd Kraft <fedd@sql.ru>:
> Hi,
>
> I think I have problems in my software because the implementation of EL
> works so that the set value is coerced to the target type.
>
> I am talking about lines 153-157 of the class org.apache.el.parser
> <http://www.docjar.com/docs/api/org/apache/el/parser/package-index.html>.AstValue.
> I guess it makes sence all the time except if the 'base' is the Map. I seem
> that once I put a String into the Map, I lose the ability to put, say, an
> array or a Collection there through the setValue method of the
> ValueExpression.
>
> The ValueExpressioni s a property of the Map, like this ${map.key}. If this
> expression is String, I can't setValue a Collection there, my collection
> becomes a String through toString method, because the resolver.getType
> method returns the Class of what is currently kept under this key.
>
> Please tell me whether this is an intended/unavoidable behaviour, or a bug?
>

I think you can file a bug, but please provide a working example that
reproduces the issue.


If I see it correctly, reading "expression_language-2_2-mrel-spec.pdf"
1) ch.1.2.1.1 says
"In the case of lvalues, the expected type is ignored and the provided value is
coerced to the actual type of the property the expression points to, before that
property is set."

2) assigning of a value to a map entry should be handled by
MapELResolver, which Javadoc is in ch.2.15. The getType() call there
is documented to return Object.class.

Implementation of javax.el.ELResolver#getType() in trunk performs a
bit differently.

BTW, a workaround in your case might be to do assignment in two steps:
 first assign null, and then assign the actual value.

Best regards,
Konstantin Kolinko

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


Mime
View raw message