Author: hlship
Date: Thu Jan 4 18:21:00 2007
New Revision: 492854
URL: http://svn.apache.org/viewvc?view=rev&rev=492854
Log:
Fix a bug where indexed properties would cause an NPE inside the
PropertyAdapterImpl constructor.
Added:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/BeanWithIndexedProperty.java
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassPropertyAdapterImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccess.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImplTest.java
Added:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/BeanWithIndexedProperty.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/BeanWithIndexedProperty.java?view=auto&rev=492854
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/BeanWithIndexedProperty.java
(added)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/BeanWithIndexedProperty.java
Thu Jan 4 18:21:00 2007
@@ -0,0 +1,14 @@
+package org.apache.tapestry.ioc.internal.services;
+
+public class BeanWithIndexedProperty
+{
+ public int getPrimitiveProperty()
+ {
+ return 0;
+ }
+
+ public String getIndexedProperty(int index)
+ {
+ return null;
+ }
+}
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassPropertyAdapterImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassPropertyAdapterImpl.java?view=diff&rev=492854&r1=492853&r2=492854
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassPropertyAdapterImpl.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassPropertyAdapterImpl.java
Thu Jan 4 18:21:00 2007
@@ -36,6 +36,11 @@
for (PropertyDescriptor pd : descriptors)
{
+ // Indexed properties will have a null propertyType (and a non-null
+ // indexedPropertyType). We ignore indexed properties.
+
+ if (pd.getPropertyType() == null) continue;
+
PropertyAdapter pa = new PropertyAdapterImpl(pd);
_adapters.put(pa.getName(), pa);
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java?view=diff&rev=492854&r1=492853&r2=492854
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java
Thu Jan 4 18:21:00 2007
@@ -12,42 +12,42 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
-
-import java.util.List;
-
-/**
- * Organizes all [EMAIL PROTECTED]
org.apache.tapestry.ioc.services.PropertyAdapter}s for a particular class.
- *
- *
- */
-public interface ClassPropertyAdapter
-{
- /** Returns the names of all properties, sorted into alphabetic order. */
- List<String> getPropertyNames();
-
- /**
- * Returns the property adapter with the given name, or null if no such
adapter exists.
- */
- PropertyAdapter getPropertyAdapter(String name);
-
- /**
- * Reads the value of a property.
- *
- * @throws UnsupportedOperationException
- * if the property is write only
- * @throws IllegalArgumentException
- * if property does not exist
- */
- Object get(Object instance, String propertyName);
-
- /**
- * Updates the value of a property. *
- *
- * @throws UnsupportedOperationException
- * if the property is read only
- * @throws IllegalArgumentException
- * if property does not exist
- */
- void set(Object instance, String propertyName, Object value);
-}
+package org.apache.tapestry.ioc.services;
+
+import java.util.List;
+
+/**
+ * Organizes all [EMAIL PROTECTED]
org.apache.tapestry.ioc.services.PropertyAdapter}s for a particular class. *
+ * <p>
+ * Only provides access to <em>simple</em> properties. Indexed properties are
ignored.
+ */
+public interface ClassPropertyAdapter
+{
+ /** Returns the names of all properties, sorted into alphabetic order. */
+ List<String> getPropertyNames();
+
+ /**
+ * Returns the property adapter with the given name, or null if no such
adapter exists.
+ */
+ PropertyAdapter getPropertyAdapter(String name);
+
+ /**
+ * Reads the value of a property.
+ *
+ * @throws UnsupportedOperationException
+ * if the property is write only
+ * @throws IllegalArgumentException
+ * if property does not exist
+ */
+ Object get(Object instance, String propertyName);
+
+ /**
+ * Updates the value of a property. *
+ *
+ * @throws UnsupportedOperationException
+ * if the property is read only
+ * @throws IllegalArgumentException
+ * if property does not exist
+ */
+ void set(Object instance, String propertyName, Object value);
+}
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccess.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccess.java?view=diff&rev=492854&r1=492853&r2=492854
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccess.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/PropertyAccess.java
Thu Jan 4 18:21:00 2007
@@ -12,47 +12,48 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
-
-/**
- * A wrapper around the JavaBean Introspector that allows more manageable
access to JavaBean
- * properties of objects.
- *
- *
- */
-public interface PropertyAccess
-{
- /**
- * Reads the value of a property.
- *
- * @throws UnsupportedOperationException
- * if the property is write only
- * @throws IllegalArgumentException
- * if property does not exist
- */
- Object get(Object instance, String propertyName);
-
- /**
- * Updates the value of a property.
- *
- * @throws UnsupportedOperationException
- * if the property is read only
- * @throws IllegalArgumentException
- * if property does not exist
- */
- void set(Object instance, String propertyName, Object value);
-
- /**
- * Returns the adapter for a particular object instance. A convienience
over invoking
- * [EMAIL PROTECTED] #getAdapter(Class)}.
- */
- ClassPropertyAdapter getAdapter(Object instance);
-
- /**
- * Returns the adapter used to access properties within the indicated
class.
- */
- ClassPropertyAdapter getAdapter(Class forClass);
-
- /** Discards all stored property access information, discarding all
created class adapters. */
- void clearCache();
-}
+package org.apache.tapestry.ioc.services;
+
+/**
+ * A wrapper around the JavaBean Introspector that allows more manageable
access to JavaBean
+ * properties of objects.
+ *
+ * <p>
+ * Only provides access to <em>simple</em> properties. Indexed properties are
ignored.
+ */
+public interface PropertyAccess
+{
+ /**
+ * Reads the value of a property.
+ *
+ * @throws UnsupportedOperationException
+ * if the property is write only
+ * @throws IllegalArgumentException
+ * if property does not exist
+ */
+ Object get(Object instance, String propertyName);
+
+ /**
+ * Updates the value of a property.
+ *
+ * @throws UnsupportedOperationException
+ * if the property is read only
+ * @throws IllegalArgumentException
+ * if property does not exist
+ */
+ void set(Object instance, String propertyName, Object value);
+
+ /**
+ * Returns the adapter for a particular object instance. A convienience
over invoking
+ * [EMAIL PROTECTED] #getAdapter(Class)}.
+ */
+ ClassPropertyAdapter getAdapter(Object instance);
+
+ /**
+ * Returns the adapter used to access properties within the indicated
class.
+ */
+ ClassPropertyAdapter getAdapter(Class forClass);
+
+ /** Discards all stored property access information, discarding all
created class adapters. */
+ void clearCache();
+}
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImplTest.java?view=diff&rev=492854&r1=492853&r2=492854
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImplTest.java
Thu Jan 4 18:21:00 2007
@@ -389,4 +389,12 @@
"parentProperty",
"subProperty"));
}
+
+ @Test
+ public void indexed_properties_are_ignored()
+ {
+ ClassPropertyAdapter cpa =
_access.getAdapter(BeanWithIndexedProperty.class);
+
+ assertEquals(cpa.getPropertyNames(), Arrays.asList("class",
"primitiveProperty"));
+ }
}