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

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

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

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-12194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17299665#comment-17299665 ]

ASF subversion and git services commented on OFBIZ-12194:
---------------------------------------------------------

Commit 2c1a395df6785ab6402045cf40d4c511d6172788 in ofbiz-framework's branch refs/heads/trunk from Jacques Le Roux
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=2c1a395 ]

Improved: Remove deprecated ByteWrapper class (OFBIZ-12194)

Removes SqlJdbcUtil::deserializeField and its usage

BY accident I formatted the whole. I had to complete it by hand and I think
it's better as is


> 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)