-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List conversion does not honor specified type #6
Comments
There is a type cast exception when use ArrayList Long |
When I replace I'm using I'm getting
|
I think following code from mvel org.mvel2.PropertyAccessor is the exception source: if (curr instanceof Map) {
//noinspection unchecked
((Map) curr).put(eval(ex, this.ctx, this.variableFactory), value);
}
else if (curr instanceof List) {
//noinspection unchecked
((List) curr).set(eval(ex, this.ctx, this.variableFactory, Integer.class), value);
}
else if (hasPropertyHandler(curr.getClass())) {
getPropertyHandler(curr.getClass()).setProperty(ex, ctx, variableFactory, value);
}
else if (curr.getClass().isArray()) {
Array.set(curr, eval(ex, this.ctx, this.variableFactory, Integer.class), convert(value, getBaseComponentType(curr.getClass())));
} But I'm not sure yet |
I just add a test to PropertyAccessTests in MVEL public class Datas {
private List<Long> ids = new ArrayList<Long>();
public void setIds(List<Long> ids) {
this.ids = ids;
}
public List<Long> getIds() {
return this.ids;
}
}
public void testBindingConvert() {
Datas datas = new Datas();
List values = new ArrayList();
values.add("1");
values.add("2");
values.add("3");
MVEL.setProperty(datas, "ids", values);
assertEquals(new Long(1),datas.getIds().get(0));
} and got this:
|
Have you tried registering a converter? Is this issue still happening? |
Conversion succeeds, but objects stored in
ids
list are String instances "1", "2", "3" not 1L, 2L, 3L.The text was updated successfully, but these errors were encountered: