commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mauricio (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (BEANUTILS-485) BeanUtils.setProperty set wrong newValue for a DynaBean with a Map Property
Date Fri, 25 Mar 2016 20:46:25 GMT

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

Mauricio updated BEANUTILS-485:
-------------------------------
    Description: 
After 1.8.3 this stop to work and my legacy Struts 1.x application starting to have bugs...
:(

Before was String.... now is String array ? Why ?


{code:title= BeanUtilsTest.java|borderStyle=solid}
	@Test
	public void testSetPropertyBeanUtils183_ok_butFailOn192() throws Exception {
		String[] value = { "odd" };

		DynaBean dynaForm = createForm();
		String propertyName = "mapProperty(one)";

		BeanUtils.setProperty(dynaForm, propertyName, value);

		@SuppressWarnings("unchecked")
		Map<String, Object> retrived = (Map<String, Object>) dynaForm
				.get("mapProperty");

		// on bean utils 1.7.0, 1.8.0 ... 1.8.3 is OK
		assertThat(retrived.get("one"), instanceOf(String.class));
		assertThat(retrived.get("one"), equalTo((Object) "odd"));

		// after 1.9.0 ... 1.9.2 is the problem...
		// assertThat(retrived.get("one"), instanceOf(String[].class));

	}

	private static DynaBean createForm() {
		DynaClass dynaClass = new BasicDynaClass("MyForm", null,
				new DynaProperty[] { new DynaProperty("mapProperty",
						java.util.HashMap.class) });

		try {
			DynaBean p = dynaClass.newInstance();
			// initialize
			p.set("mapProperty", new HashMap<>());
			return p;
		} catch (IllegalAccessException | InstantiationException ex) {
			throw new RuntimeException(ex);
		}

	}

{code}


  was:
After 1.8.3 this stop to work and my legacy Struts 1.x application starting to have bugs...
:(

Before was String.... now is String array ? Why ?

public class BeanUtilsTest {

	@Test
	public void testSetPropertyBeanUtils183_ok_butFailOn192() throws Exception {
		String[] value = { "odd" };

		DynaBean dynaForm = createForm();
		String propertyName = "mapProperty(one)";

		BeanUtils.setProperty(dynaForm, propertyName, value);

		@SuppressWarnings("unchecked")
		Map<String, Object> retrived = (Map<String, Object>) dynaForm
				.get("mapProperty");

		// on bean utils 1.7.0, 1.8.0 ... 1.8.3 is OK
		assertThat(retrived.get("one"), instanceOf(String.class));
		assertThat(retrived.get("one"), equalTo((Object) "odd"));

		// after 1.9.0 ... 1.9.2 is the problem...
		// assertThat(retrived.get("one"), instanceOf(String[].class));

	}

	private static DynaBean createForm() {
		DynaClass dynaClass = new BasicDynaClass("MyForm", null,
				new DynaProperty[] { new DynaProperty("mapProperty",
						java.util.HashMap.class) });

		try {
			DynaBean p = dynaClass.newInstance();
			// initialize
			p.set("mapProperty", new HashMap<>());
			return p;
		} catch (IllegalAccessException | InstantiationException ex) {
			throw new RuntimeException(ex);
		}

	}



> BeanUtils.setProperty set wrong newValue for a DynaBean with a Map Property
> ---------------------------------------------------------------------------
>
>                 Key: BEANUTILS-485
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-485
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.9.0, 1.9.1, 1.9.2
>            Reporter: Mauricio
>
> After 1.8.3 this stop to work and my legacy Struts 1.x application starting to have bugs...
:(
> Before was String.... now is String array ? Why ?
> {code:title= BeanUtilsTest.java|borderStyle=solid}
> 	@Test
> 	public void testSetPropertyBeanUtils183_ok_butFailOn192() throws Exception {
> 		String[] value = { "odd" };
> 		DynaBean dynaForm = createForm();
> 		String propertyName = "mapProperty(one)";
> 		BeanUtils.setProperty(dynaForm, propertyName, value);
> 		@SuppressWarnings("unchecked")
> 		Map<String, Object> retrived = (Map<String, Object>) dynaForm
> 				.get("mapProperty");
> 		// on bean utils 1.7.0, 1.8.0 ... 1.8.3 is OK
> 		assertThat(retrived.get("one"), instanceOf(String.class));
> 		assertThat(retrived.get("one"), equalTo((Object) "odd"));
> 		// after 1.9.0 ... 1.9.2 is the problem...
> 		// assertThat(retrived.get("one"), instanceOf(String[].class));
> 	}
> 	private static DynaBean createForm() {
> 		DynaClass dynaClass = new BasicDynaClass("MyForm", null,
> 				new DynaProperty[] { new DynaProperty("mapProperty",
> 						java.util.HashMap.class) });
> 		try {
> 			DynaBean p = dynaClass.newInstance();
> 			// initialize
> 			p.set("mapProperty", new HashMap<>());
> 			return p;
> 		} catch (IllegalAccessException | InstantiationException ex) {
> 			throw new RuntimeException(ex);
> 		}
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message