Commits

musachy  committed c65fd5a

WW-2513 EnumMap's not supported in type conversion + InstantiationException

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

  • Participants
  • Parent commits 468ef96

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork2/conversion/impl/InstantiatingNullHandler.java

 
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.conversion.NullHandler;
+import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
     private static final Logger LOG = LoggerFactory.getLogger(InstantiatingNullHandler.class);
     private ReflectionProvider reflectionProvider;
     private ObjectFactory objectFactory;
-    
+    private ObjectTypeDeterminer objectTypeDeterminer;
+
+    @Inject
+    public void setObjectTypeDeterminer(ObjectTypeDeterminer det) {
+        this.objectTypeDeterminer = det;
+    }
+
     @Inject
     public void setReflectionProvider(ReflectionProvider prov) {
         this.reflectionProvider = prov;
     }
-    
+
     @Inject
     public void setObjectFactory(ObjectFactory fac) {
         this.objectFactory = fac;
     }
-    
+
     public Object nullMethodResult(Map<String, Object> context, Object target, String methodName, Object[] args) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Entering nullMethodResult ");
             return new ArrayList();
         } else if (clazz == Map.class) {
             return new HashMap();
+        } else if (clazz == EnumMap.class) {
+            Class keyClass = objectTypeDeterminer.getKeyClass(target.getClass(), property);
+            return new EnumMap(keyClass);
         }
 
         return objectFactory.buildBean(clazz, context);