svn commit: r586041 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r586041 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java

doogie-3
Author: doogie
Date: Thu Oct 18 10:35:07 2007
New Revision: 586041

URL: http://svn.apache.org/viewvc?rev=586041&view=rev
Log:
Fix for javac's broken type inferring.  If an array with length one
is passed to toMap, and the single value is an instance of a Map,
then try to cast it to a map.

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java?rev=586041&r1=586040&r2=586041&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java Thu Oct 18 10:35:07 2007
@@ -150,6 +150,10 @@
         if (data == null) {
             return null;
         }
+        if (data.length == 1 && data[0] instanceof Map) {
+            // Fix for javac's broken type inferring
+            return UtilGenerics.<K, V>checkMap(data[0]);
+        }
         if (data.length % 2 == 1) {
             throw new IllegalArgumentException("You must pass an even sized array to the toMap method");
         }