Revision: 1184
http://stripes.svn.sourceforge.net/stripes/?rev=1184&view=rev
Author: bengunter
Date: 2009-10-22 02:43:35 +0000 (Thu, 22 Oct 2009)
Log Message:
-----------
STS-664: Create a copy of the array of property descriptors so that if and when
we poke a BridgePropertyDescriptor into the array, we don't affect the cache
maintained by Introspector. Also added a missing @Override to the unit test
class.
Modified Paths:
--------------
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/ReflectUtil.java
branches/1.5.x/tests/src/net/sourceforge/stripes/validation/ValidationWithGenericsTest.java
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/ReflectUtil.java
===================================================================
--- branches/1.5.x/stripes/src/net/sourceforge/stripes/util/ReflectUtil.java
2009-10-22 02:25:42 UTC (rev 1183)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/util/ReflectUtil.java
2009-10-22 02:43:35 UTC (rev 1184)
@@ -497,20 +497,26 @@
}
@Override
- public synchronized void setReadMethod(Method readMethod) throws
IntrospectionException {
+ public synchronized void setReadMethod(Method readMethod) {
this.readMethod = readMethod;
}
@Override
- public synchronized void setWriteMethod(Method writeMethod) throws
IntrospectionException {
+ public synchronized void setWriteMethod(Method writeMethod) {
this.writeMethod = writeMethod;
}
}
// Not cached yet. Look it up the normal way.
try {
+ // Make a copy of the array to avoid poking stuff into
Introspector's cache!
PropertyDescriptor[] pds =
Introspector.getBeanInfo(clazz).getPropertyDescriptors();
+ pds = Arrays.asList(pds).toArray(new
PropertyDescriptor[pds.length]);
+
+ // Make a new local cache entry
Map<String, PropertyDescriptor> map = new LinkedHashMap<String,
PropertyDescriptor>();
+
+ // Check each descriptor for bridge methods and handle accordingly
for (int i = 0; i < pds.length; i++) {
PropertyDescriptor pd = pds[i];
if ((pd.getReadMethod() != null &&
pd.getReadMethod().isBridge())
@@ -523,7 +529,7 @@
map.put(pd.getName(), pd);
}
- // Put cache entry
+ // Put local cache entry
propertyDescriptors.put(clazz, map);
return pds;
Modified:
branches/1.5.x/tests/src/net/sourceforge/stripes/validation/ValidationWithGenericsTest.java
===================================================================
---
branches/1.5.x/tests/src/net/sourceforge/stripes/validation/ValidationWithGenericsTest.java
2009-10-22 02:25:42 UTC (rev 1183)
+++
branches/1.5.x/tests/src/net/sourceforge/stripes/validation/ValidationWithGenericsTest.java
2009-10-22 02:43:35 UTC (rev 1184)
@@ -42,6 +42,7 @@
@Validate(field = "password", required = true)
})
public User getModel() { return super.getModel(); }
+ @Override
public void setModel(User user) { super.setModel(user); }
public Resolution login() { return null; }
}
@@ -130,4 +131,8 @@
Assert.assertEquals(bean.getModel().getUsername(), "Scooby");
Assert.assertEquals(bean.getModel().getPassword(), "Shaggy");
}
+
+ public static void main(String[] args) throws Exception {
+ new ValidationWithGenericsTest().testActionBeanWithTypeParameter();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development