You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2021/03/11 11:08:48 UTC

[ofbiz-framework] branch trunk updated: Improved: Remove deprecated ByteWrapper class (OFBIZ-12194)

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9f8ff62  Improved: Remove deprecated ByteWrapper class (OFBIZ-12194)
9f8ff62 is described below

commit 9f8ff6255c16c67440a1d7f8170835fb3b39359d
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Thu Mar 11 12:07:02 2021 +0100

    Improved: Remove deprecated ByteWrapper class (OFBIZ-12194)
    
    This due for many years
    
    NOTE DEJ20071022: the use of ByteWrapper is not recommended and is deprecated,
    only old data should be stored that way.
    
    I have still to verify the implication of removing
    deserializeField() in SqlJdbcUtil.getValue()
---
 .../org/apache/ofbiz/entity/GenericEntity.java     |  9 ---
 .../org/apache/ofbiz/entity/util/ByteWrapper.java  | 65 ----------------------
 2 files changed, 74 deletions(-)

diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
index 1c6e0c1..83f08af 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
@@ -884,7 +884,6 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
      * @param name the name
      * @return the byte [ ]
      */
-    @SuppressWarnings("deprecation")
     public byte[] getBytes(String name) {
         Object value = get(name);
         if (value == null) {
@@ -903,14 +902,6 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
         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();
-        }
         // uh-oh, this shouldn't happen...
         throw new IllegalArgumentException("In call to getBytes the value is not a supported type, should be byte[] or ByteWrapper, is: "
                 + value.getClass().getName());
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/ByteWrapper.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/ByteWrapper.java
deleted file mode 100644
index 27639d8..0000000
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/ByteWrapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ofbiz.entity.util;
-
-import java.io.Serializable;
-
-/**
- * @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
- *
- * A very simple class to wrap a byte array for persistence.
- */
-@SuppressWarnings("serial")
-@Deprecated
-public class ByteWrapper implements Serializable {
-    private byte[] bytes;
-
-    protected ByteWrapper() { }
-
-    public ByteWrapper(byte[] bytes) {
-        this.bytes = bytes;
-    }
-
-    /**
-     * Get bytes byte [ ].
-     * @return the byte [ ]
-     */
-    public byte[] getBytes() {
-        return bytes;
-    }
-
-    /**
-     * Gets byte.
-     * @param pos the pos
-     * @return the byte
-     */
-    public byte getByte(int pos) {
-        return bytes[pos];
-    }
-
-    /**
-     * Gets length.
-     * @return the length
-     */
-    public int getLength() {
-        return bytes.length;
-    }
-}