commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomáš Procházka (JIRA) <j...@apache.org>
Subject [jira] Created: (BEANUTILS-314) BeanUtils.describe() doesn't handle corectly array fields like String[]
Date Thu, 15 May 2008 13:09:55 GMT
BeanUtils.describe() doesn't handle corectly array fields like String[]
-----------------------------------------------------------------------

                 Key: BEANUTILS-314
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-314
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.8.0-BETA, 1.7.0
         Environment: Windows XP, Java 1.6.0_10-beta-b13
            Reporter: Tomáš Procházka


When bean has array field like String[] , BeanUtils.describe()  doesn't add String[] to Map,
but get only first array item and convert it to String. But BeanUtils.populate(b, tMap) correctly
set String[] from map to bean property.

Here is example:

public class BeanTest {

	public static void main(String[] args) throws Exception {
		BeanTest bt = new BeanTest();
		bt.test();
	}

	private void test() throws Exception {
		Bean b = new Bean();
		b.setData(new String[]{"a", "b", "c"});
		b.setName("ahoj");
		Map map = BeanUtils.describe(b);
		System.out.println(map.get("data"));
		System.out.println(map.get("name"));
	}

	public class Bean {

		public String[] getData() {
			return data;
		}

		public void setData(String[] data) {
			this.data = data;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
		private String[] data;
		private String name;
	}
}

Expected result:

System.out.println(map.get("data"));
must return String[] with {"a", "b", "c"}.

This bug is in 1.70 and also in 1.8.0

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message