Remove ByteWrapper class

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

Remove ByteWrapper class

Jacques Le Roux
Administrator
Hi,

Here is a comment from David in 2007 in the ByteWrapper class

  * @deprecated
  * NOTE DEJ20071022: deprecating this because we want to save the byte[] directly instead of inside a serialized
  * object, which makes it hard for other apps to use the data, and causes problems if this object is ever updated

Here is another comment where it's used, in GenericEntity.getBytes()

         if (value instanceof byte[]) {
             return (byte[]) value;
         }
         if (value instanceof org.apache.ofbiz.entity.util.ByteWrapper) {
             // NOTE DEJ20071022: the use of ByteWrapper is not recommended and is deprecated, only old data should be stored that way
             Debug.logWarning("Found a ByteWrapper object in the database for field [" + this.getEntityName() + "." + name + "]; converting to byte[]
and returning, but note that you need to update your database to unwrap these objects for future compatibility", module);
             org.apache.ofbiz.entity.util.ByteWrapper wrapper = (org.apache.ofbiz.entity.util.ByteWrapper) value;
             return wrapper.getBytes();
         }

Here is another related comment (in SqlJdbcUtil.deserializeField())

         // NOTE DEJ20071022: the following code is to convert the byte[] back into an object; if that fails
         //just return the byte[]; this was for the ByteWrapper thing which is now deprecated, so this may
         //be removed in the near future to enhance performance

Where there is also this code commented out

         //alt 1: binaryInput = rs.getBinaryStream(ind);
         //alt 2: Blob blobLocator = rs.getBlob(ind);
         //if (blobLocator != null) {
         //    binaryInput = blobLocator.getBinaryStream();
         //}

deserializeField() is only used (twice) in SqlJdbcUtil.getValue() and here are the concerned types (11 & 12):

         fieldTypeMap.put("java.lang.Object", 11);
         fieldTypeMap.put("Object", 11);

         fieldTypeMap.put("java.sql.Blob", 12);
         fieldTypeMap.put("Blob", 12);
         fieldTypeMap.put("byte[]", 12);
         fieldTypeMap.put("java.nio.ByteBuffer", 12);
         fieldTypeMap.put("java.nio.HeapByteBuffer", 12);

And I think we can clean this 2 cases from the ByteWrapper class . So it was 10 years ago, opinions before I open a Jira ?

Jacques

Reply | Threaded
Open this post in threaded view
|

Re: Remove ByteWrapper class

Nicolas Malin-2
deprecated before apache integration :) so +1


Le 13/08/2017 à 16:44, Jacques Le Roux a écrit :

> Hi,
>
> Here is a comment from David in 2007 in the ByteWrapper class
>
>  * @deprecated
>  * NOTE DEJ20071022: deprecating this because we want to save the
> byte[] directly instead of inside a serialized
>  * object, which makes it hard for other apps to use the data, and
> causes problems if this object is ever updated
>
> Here is another comment where it's used, in GenericEntity.getBytes()
>
>         if (value instanceof byte[]) {
>             return (byte[]) value;
>         }
>         if (value instanceof org.apache.ofbiz.entity.util.ByteWrapper) {
>             // NOTE DEJ20071022: the use of ByteWrapper is not
> recommended and is deprecated, only old data should be stored that way
>             Debug.logWarning("Found a ByteWrapper object in the
> database for field [" + this.getEntityName() + "." + name + "];
> converting to byte[] and returning, but note that you need to update
> your database to unwrap these objects for future compatibility", module);
>             org.apache.ofbiz.entity.util.ByteWrapper wrapper =
> (org.apache.ofbiz.entity.util.ByteWrapper) value;
>             return wrapper.getBytes();
>         }
>
> Here is another related comment (in SqlJdbcUtil.deserializeField())
>
>         // NOTE DEJ20071022: the following code is to convert the
> byte[] back into an object; if that fails
>         //just return the byte[]; this was for the ByteWrapper thing
> which is now deprecated, so this may
>         //be removed in the near future to enhance performance
>
> Where there is also this code commented out
>
>         //alt 1: binaryInput = rs.getBinaryStream(ind);
>         //alt 2: Blob blobLocator = rs.getBlob(ind);
>         //if (blobLocator != null) {
>         //    binaryInput = blobLocator.getBinaryStream();
>         //}
>
> deserializeField() is only used (twice) in SqlJdbcUtil.getValue() and
> here are the concerned types (11 & 12):
>
>         fieldTypeMap.put("java.lang.Object", 11);
>         fieldTypeMap.put("Object", 11);
>
>         fieldTypeMap.put("java.sql.Blob", 12);
>         fieldTypeMap.put("Blob", 12);
>         fieldTypeMap.put("byte[]", 12);
>         fieldTypeMap.put("java.nio.ByteBuffer", 12);
>         fieldTypeMap.put("java.nio.HeapByteBuffer", 12);
>
> And I think we can clean this 2 cases from the ByteWrapper class . So
> it was 10 years ago, opinions before I open a Jira ?
>
> Jacques
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Remove ByteWrapper class

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
Hi,

I created https://issues.apache.org/jira/browse/OFBIZ-12194 for that

Le 07/03/2021 à 18:32, Jacques Le Roux a écrit :

> Here is a comment from David in 2007 in the ByteWrapper class
>
>  * @deprecated
>  * NOTE DEJ20071022: deprecating this because we want to save the byte[] directly instead of inside a serialized
>  * object, which makes it hard for other apps to use the data, and causes problems if this object is ever updated
>
> Here is another comment where it's used, in GenericEntity.getBytes()
>
>         if (value instanceof byte[]) {
>             return (byte[]) value;
>         }
>         if (value instanceof org.apache.ofbiz.entity.util.ByteWrapper) {
>             // NOTE DEJ20071022: the use of ByteWrapper is not recommended and is deprecated, only old data should be stored that way
>             Debug.logWarning("Found a ByteWrapper object in the database for field [" + this.getEntityName() + "." + name + "]; converting to byte[]
> and returning, but note that you need to update your database to unwrap these objects for future compatibility", module);
>             org.apache.ofbiz.entity.util.ByteWrapper wrapper = (org.apache.ofbiz.entity.util.ByteWrapper) value;
>             return wrapper.getBytes();
>         }
>
> Here is another related comment (in SqlJdbcUtil.deserializeField())
>
>         // NOTE DEJ20071022: the following code is to convert the byte[] back into an object; if that fails
>         //just return the byte[]; this was for the ByteWrapper thing which is now deprecated, so this may
>         //be removed in the near future to enhance performance
>
> Where there is also this code commented out
>
>         //alt 1: binaryInput = rs.getBinaryStream(ind);
>         //alt 2: Blob blobLocator = rs.getBlob(ind);
>         //if (blobLocator != null) {
>         //    binaryInput = blobLocator.getBinaryStream();
>         //}
>
> deserializeField() is only used (twice) in SqlJdbcUtil.getValue() and here are the concerned types (11 & 12):
>
>         fieldTypeMap.put("java.lang.Object", 11);
>         fieldTypeMap.put("Object", 11);
>
>         fieldTypeMap.put("java.sql.Blob", 12);
>         fieldTypeMap.put("Blob", 12);
>         fieldTypeMap.put("byte[]", 12);
>         fieldTypeMap.put("java.nio.ByteBuffer", 12);
>         fieldTypeMap.put("java.nio.HeapByteBuffer", 12);
>
> And I think we can clean this 2 cases from the ByteWrapper class . So it was 10 years ago, opinions before I open a Jira ?

Reply | Threaded
Open this post in threaded view
|

Re: Remove ByteWrapper class

Jacques Le Roux
Administrator
Done

Le 08/03/2021 à 11:29, Jacques Le Roux a écrit :

> Hi,
>
> I created https://issues.apache.org/jira/browse/OFBIZ-12194 for that
>
> Le 07/03/2021 à 18:32, Jacques Le Roux a écrit :
>> Here is a comment from David in 2007 in the ByteWrapper class
>>
>>  * @deprecated
>>  * NOTE DEJ20071022: deprecating this because we want to save the byte[] directly instead of inside a serialized
>>  * object, which makes it hard for other apps to use the data, and causes problems if this object is ever updated
>>
>> Here is another comment where it's used, in GenericEntity.getBytes()
>>
>>         if (value instanceof byte[]) {
>>             return (byte[]) value;
>>         }
>>         if (value instanceof org.apache.ofbiz.entity.util.ByteWrapper) {
>>             // NOTE DEJ20071022: the use of ByteWrapper is not recommended and is deprecated, only old data should be stored that way
>>             Debug.logWarning("Found a ByteWrapper object in the database for field [" + this.getEntityName() + "." + name + "]; converting to
>> byte[] and returning, but note that you need to update your database to unwrap these objects for future compatibility", module);
>>             org.apache.ofbiz.entity.util.ByteWrapper wrapper = (org.apache.ofbiz.entity.util.ByteWrapper) value;
>>             return wrapper.getBytes();
>>         }
>>
>> Here is another related comment (in SqlJdbcUtil.deserializeField())
>>
>>         // NOTE DEJ20071022: the following code is to convert the byte[] back into an object; if that fails
>>         //just return the byte[]; this was for the ByteWrapper thing which is now deprecated, so this may
>>         //be removed in the near future to enhance performance
>>
>> Where there is also this code commented out
>>
>>         //alt 1: binaryInput = rs.getBinaryStream(ind);
>>         //alt 2: Blob blobLocator = rs.getBlob(ind);
>>         //if (blobLocator != null) {
>>         //    binaryInput = blobLocator.getBinaryStream();
>>         //}
>>
>> deserializeField() is only used (twice) in SqlJdbcUtil.getValue() and here are the concerned types (11 & 12):
>>
>>         fieldTypeMap.put("java.lang.Object", 11);
>>         fieldTypeMap.put("Object", 11);
>>
>>         fieldTypeMap.put("java.sql.Blob", 12);
>>         fieldTypeMap.put("Blob", 12);
>>         fieldTypeMap.put("byte[]", 12);
>>         fieldTypeMap.put("java.nio.ByteBuffer", 12);
>>         fieldTypeMap.put("java.nio.HeapByteBuffer", 12);
>>
>> And I think we can clean this 2 cases from the ByteWrapper class . So it was 10 years ago, opinions before I open a Jira ?
>