You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Jacques Le Roux (Jira)" <ji...@apache.org> on 2021/03/08 09:47:00 UTC

[jira] [Assigned] (OFBIZ-12194) Remove deprecated ByteWrapper class

     [ https://issues.apache.org/jira/browse/OFBIZ-12194?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux reassigned OFBIZ-12194:
---------------------------------------

          Component/s: framework/entity
        Fix Version/s: Upcoming Branch
    Affects Version/s: Trunk
             Assignee: Jacques Le Roux

> Remove deprecated ByteWrapper class   
> --------------------------------------
>
>                 Key: OFBIZ-12194
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-12194
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework/entity
>    Affects Versions: Trunk
>            Reporter: Jacques Le Roux
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: Upcoming Branch
>
>
> [I send a message about it to dev ML in mid 2017|https://markmail.org/message/4we6tognqbck42df]: 
> {quote}
> 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 ?
> {quote}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)