Commits

rainerh  committed a60431b

Tiger type conversion uses the wrong class for Map values
Issue number: XW-327
Obtained from:
Submitted by: Tobias J�rlund
Reviewed by: Rainer Hermanns

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@768e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits d850e32

Comments (0)

Files changed (1)

File tiger/src/java/com/opensymphony/xwork/util/GenericsObjectTypeDeterminer.java

  */
 public class GenericsObjectTypeDeterminer extends DefaultObjectTypeDeterminer {
     public Class getKeyClass(Class parentClass, String property) {
-        Class clazz = getClass(parentClass, property, 0);
+        Class clazz = getClass(parentClass, property, false);
         if (clazz != null) {
             return clazz;
         } else {
     }
 
     public Class getElementClass(Class parentClass, String property, Object key) {
-        int index = 0;
-        if (Map.class.isAssignableFrom(parentClass)) {
-            index = 1;
-        }
-
-        Class clazz = getClass(parentClass, property, index);
-        if (clazz != null) {
-            return clazz;
-        } else {
+        Class clazz = getClass(parentClass, property, true);
+         if (clazz != null) {
+             return clazz;
+         } else {
             return super.getElementClass(parentClass, property, key);
         }
     }
         return super.getKeyProperty(parentClass, property);
     }
 
-    private Class getClass(Class parentClass, String property, int index) {
+    private Class getClass(Class parentClass, String property, boolean element) {
         Field field = OgnlRuntime.getField(parentClass, property);
         if (field == null) {
             return null;
         }
         Type genericType = field.getGenericType();
         if (genericType instanceof ParameterizedType) {
+            int index = (element && Map.class.isAssignableFrom(field.getType())) ? 1 : 0;
             ParameterizedType type = (ParameterizedType) genericType;
 
             return (Class) type.getActualTypeArguments()[index];