Author: adrianc
Date: Tue Nov 24 18:37:09 2009 New Revision: 883807 URL: http://svn.apache.org/viewvc?rev=883807&view=rev Log: Converter framework bug fixes. This commit fixes the out of memory errors the demo servers have been having lately. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java?rev=883807&r1=883806&r2=883807&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java Tue Nov 24 18:37:09 2009 @@ -92,6 +92,11 @@ return (Converter<S, T>) value; } } + // Null converter must be checked last + if (nullConverter.canConvert(sourceClass, targetClass)) { + converterMap.put(key, nullConverter); + return (Converter<S, T>) nullConverter; + } noConversions.add(key); Debug.logWarning("*** No converter found, converting from " + sourceClass.getName() + " to " + targetClass.getName() + @@ -149,7 +154,6 @@ */ protected static class NullConverter implements Converter<Object, Object> { public NullConverter() { - Converters.registerConverter(this); } public boolean canConvert(Class<?> sourceClass, Class<?> targetClass) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java?rev=883807&r1=883806&r2=883807&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java Tue Nov 24 18:37:09 2009 @@ -31,6 +31,20 @@ public static final int CHAR_BUFFER_SIZE = 4096; + public static class BlobToBlob extends AbstractConverter<Blob, Blob> { + public BlobToBlob() { + super(Blob.class, Blob.class); + } + + public Blob convert(Blob obj) throws ConversionException { + try { + return new javax.sql.rowset.serial.SerialBlob(obj.getBytes(1, (int) obj.length())); + } catch (Exception e) { + throw new ConversionException(e); + } + } + } + public static class BlobToByteArray extends AbstractConverter<Blob, byte[]> { public BlobToByteArray() { super(Blob.class, byte[].class); @@ -38,7 +52,7 @@ public byte[] convert(Blob obj) throws ConversionException { try { - return obj.getBytes(1, Integer.MAX_VALUE); + return obj.getBytes(1, (int) obj.length()); } catch (Exception e) { throw new ConversionException(e); } |
Free forum by Nabble | Edit this page |