Adrian Crum wrote:
> doo...@apache.org wrote:
>> Author: doogie
>> Date: Mon Mar  1 05:06:16 2010
>> New Revision: 917376
>>
>> URL: http://svn.apache.org/viewvc?rev=917376&view=rev
>> Log:
>> BUG FIX: Move the check that tests whether we are converting to the
>> passed object to before the loadClass call.
>>
>> Modified:
>>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=917376&r1=917375&r2=917376&view=diff
>>
>> ==============================================================================
>>
>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
>> (original)
>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
>> Mon Mar  1 05:06:16 2010
>> @@ -484,6 +484,9 @@
>>              return obj.toString();
>>          }
>>          Class<?> sourceClass = obj.getClass();
>> +        if (sourceClass.getName().equals(type)) {
>> +            return obj;
>> +        }
>>          if ("Object".equals(type) || "java.lang.Object".equals(type)) {
>>              return obj;
>>          }
> 
> Are you sure this will work? Take a look at the following if statement.

Yes, due a combination of things.

If the object was null, return null.

If converting to the same exact class as the incoming obj, return with
no change.

If the incoming object is a string, and it is empty, return null.

The above 3 constraints were pulled from the old version of
simpleTypeConvert.

Without all three, if you tried to convert an empty String to a
String, you'd get null.

Reply via email to