rdonkin 2002/09/24 11:45:54
Modified: beanutils/src/java/org/apache/commons/beanutils
PropertyUtils.java
beanutils/src/test/org/apache/commons/beanutils
PropertyUtilsTestCase.java TestBean.java
Log:
Fix for bug #10478. Submitted by Roland Huss.
Revision Changes Path
1.31 +8 -5
jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java
Index: PropertyUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- PropertyUtils.java 21 Jul 2002 00:20:44 -0000 1.30
+++ PropertyUtils.java 24 Sep 2002 18:45:54 -0000 1.31
@@ -708,8 +708,11 @@
int indexOfMAPPED_DELIM2 = -1;
int indexOfNESTED_DELIM = -1;
while (true) {
+ indexOfNESTED_DELIM = name.indexOf(NESTED_DELIM);
+ indexOfMAPPED_DELIM = name.indexOf(MAPPED_DELIM);
indexOfMAPPED_DELIM2 = name.indexOf(MAPPED_DELIM2);
- if (indexOfMAPPED_DELIM2 >= 0) {
+ if (indexOfMAPPED_DELIM2 >= 0 && indexOfMAPPED_DELIM >=0 &&
+ (indexOfNESTED_DELIM < 0 || indexOfNESTED_DELIM >
indexOfMAPPED_DELIM)) {
indexOfNESTED_DELIM =
name.indexOf(NESTED_DELIM, indexOfMAPPED_DELIM2);
} else {
1.22 +14 -4
jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java
Index: PropertyUtilsTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- PropertyUtilsTestCase.java 21 Jul 2002 00:20:45 -0000 1.21
+++ PropertyUtilsTestCase.java 24 Sep 2002 18:45:54 -0000 1.22
@@ -1103,6 +1103,16 @@
fail("Thew exception: " + e);
}
+ try
+ {
+ assertEquals("Can't retrieved nested with mapped property",
+ "Mapped Value",
+ PropertyUtils.getNestedProperty(
+ bean,"mappedNested.value(Mapped Key)"));
+ } catch (Exception e)
+ {
+ fail("Thew exception: " + e);
+ }
}
1.13 +23 -5
jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java
Index: TestBean.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TestBean.java 22 Jul 2002 00:02:01 -0000 1.12
+++ TestBean.java 24 Sep 2002 18:45:54 -0000 1.13
@@ -347,6 +347,24 @@
}
+ /*
+ * Another nested reference to a bean containing mapp properties
+ */
+ class MappedTestBean {
+ public void setValue(String key,String val) { }
+ public String getValue(String key) { return "Mapped Value"; }
+ }
+
+ private MappedTestBean mappedNested = null;
+
+ public MappedTestBean getMappedNested() {
+ if (mappedNested == null)
+ {
+ mappedNested = new MappedTestBean();
+ }
+ return mappedNested;
+ }
+
/**
* A String property with an initial value of null.
*/
@@ -442,7 +460,7 @@
this.writeOnlyProperty = writeOnlyProperty;
}
-
+
// ------------------------------------------------------- Static Variables
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>