Author: stain
Date: Wed Sep 14 11:58:34 2016
New Revision: 1760685
URL: http://svn.apache.org/viewvc?rev=1760685&view=rev
Log:
BEANUTILS-493 handle setting by list index dynabeans
Author: Bernhard Seebass
Added:
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira493TestCase.java
Modified:
commons/proper/beanutils/trunk/src/changes/changes.xml
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
Modified: commons/proper/beanutils/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/changes/changes.xml?rev=1760685&r1=1760684&r2=1760685&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/beanutils/trunk/src/changes/changes.xml Wed Sep 14 11:58:34
2016
@@ -19,7 +19,7 @@
</properties>
<body>
- <release version="1.9.3" date="2016-06-02" description="Buf fix release">
+ <release version="1.9.3" date="2016-09-14" description="Bug fix release">
<action issue="BEANUTILS-433" dev="ggregory" type="update"
due-to="Benedikt Ritter, Gary Gregory">
Update dependency from JUnit 3.8.1 to 4.12.
</action>
@@ -44,6 +44,9 @@
<action issue="BEANUTILS-465" dev="oheger" type="fix" due-to="Daniel
Atallah">
Indexed List Setters no longer work
</action>
+ <action issue="BEANUTILS-493" dev="stain" type="fix" due-to="Bernhard
Seebass">
+ Exception when setting indexed properties: "Default conversion to
ArrayList failed"
+ </action>
</release>
<release version="1.9.2" date="2014-05-29"
Modified:
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
URL:
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java?rev=1760685&r1=1760684&r2=1760685&view=diff
==============================================================================
---
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
(original)
+++
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
Wed Sep 14 11:58:34 2016
@@ -921,6 +921,9 @@ public class BeanUtilsBean {
return; // Skip this property setter
}
type = dynaPropertyType(dynaProperty, value);
+ if (index >= 0 && List.class.isAssignableFrom(type)) {
+ type = Object.class;
+ }
} else if (target instanceof Map) {
type = Object.class;
} else if (target != null && target.getClass().isArray() && index >=
0) {
Added:
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira493TestCase.java
URL:
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira493TestCase.java?rev=1760685&view=auto
==============================================================================
---
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira493TestCase.java
(added)
+++
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira493TestCase.java
Wed Sep 14 11:58:34 2016
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.beanutils.bugs;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.beanutils.LazyDynaBean;
+import org.junit.Test;
+
+/**
+ * Test setting indexed properties on dynabeans
+ *
+ * @see <a
href="https://issues.apache.org/jira/browse/BEANUTILS-493">BEANUTILS-493</a>
+ */
+
+public class Jira493TestCase {
+
+ @Test
+ public void testIndexedProperties() throws Exception {
+ LazyDynaBean lazyDynaBean = new LazyDynaBean();
+ BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
+ beanUtilsBean.setProperty(lazyDynaBean, "x[0]", "x1");
+ beanUtilsBean.setProperty(lazyDynaBean, "x[1]", "x2");
+ Object x = lazyDynaBean.get("x");
+ assertEquals("[x1, x2]", x.toString());
+ }
+
+}
\ No newline at end of file