Author: doogie
Date: Mon Mar 1 05:05:10 2010 New Revision: 917373 URL: http://svn.apache.org/viewvc?rev=917373&view=rev Log: BUG FIX: If the object is a string and it is empty, return null early. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.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=917373&r1=917372&r2=917373&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:05:10 2010 @@ -484,6 +484,9 @@ return obj.toString(); } Class<?> sourceClass = obj.getClass(); + if (obj instanceof String && UtilValidate.isEmpty(obj)) { + return null; + } Class<?> targetClass = null; try { targetClass = loadClass(type); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=917373&r1=917372&r2=917373&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java Mon Mar 1 05:05:10 2010 @@ -399,7 +399,8 @@ Object obj = get(context, timeZone, locale); StringBuilder buffer = new StringBuilder(this.hint); try { - if (obj != null) { + if (obj instanceof String && UtilValidate.isEmpty(obj)) { + } else if (obj != null) { buffer.append(ObjectType.simpleTypeConvert(obj, "String", null, timeZone, locale, true)); } } catch (Exception e) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=917373&r1=917372&r2=917373&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Mon Mar 1 05:05:10 2010 @@ -198,7 +198,7 @@ public void testString() throws GeneralException, Exception { simpleTypeConvertTest("String->String", "one", "String", "one"); simpleTypeConvertTest("String->String", "one", "java.lang.String", "one"); - //BUG simpleTypeConvertTestSingleMulti("empty-String->anything", "", new String[] {"List", "Map"}, null); + simpleTypeConvertTestSingleMulti("empty-String->anything", "", new String[] {"List", "Map"}, null); //BUG simpleTypeConvertTestSingleMulti("empty-String->bad-class", "", new String[] {"no-class"}, null); simpleTypeConvertTestError("String->error", "one", new String[] {}); simpleTypeConvertTestMultiMulti("String->Boolean(true)", new String[] {"true", " true ", " TrUe"}, new String[] {"Boolean", "java.lang.Boolean"}, Boolean.TRUE); |
Free forum by Nabble | Edit this page |