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] Updated: (BEANUTILS-314) BeanUtils.describe() doesn't handle corectly array fields like String[]
Date Fri, 16 May 2008 18:49:55 GMT

     [ https://issues.apache.org/jira/browse/BEANUTILS-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tomáš Procházka updated BEANUTILS-314:
--------------------------------------

    Description: 
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:

{code:title=BeanTest.java|borderStyle=solid}
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;
	}
}
{code}

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

  was:
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


> 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.7.0, 1.8.0-BETA
>         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:
> {code:title=BeanTest.java|borderStyle=solid}
> 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;
> 	}
> }
> {code}
> 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