tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
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 <>:
> 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
> <>.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. 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:
For additional commands, e-mail:

View raw message