diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java index d73aa55f2c..eb7666a2c3 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java @@ -24,11 +24,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectOutputStream; import java.lang.reflect.Array; -import java.util.Arrays; import java.util.Iterator; -import java.util.List; import java.util.ServiceLoader; -import java.util.stream.Collectors; import org.apache.ofbiz.base.lang.Factory; import org.apache.ofbiz.base.lang.SourceMonitored; @@ -102,27 +99,17 @@ public final class UtilObject { return obj; } - /** Deserialize a byte array back to an object */ + /** + * Deserializes a byte array back to an object. + * + * @param bytes the array of bytes + * @return the deserialized object. + * @throws ClassNotFoundException when the class can not be deserialized. + * @throws IOException when a general Input/Output error happen. + */ public static Object getObjectException(byte[] bytes) throws ClassNotFoundException, IOException { - String listOfSafeObjectsForInputStream = UtilProperties.getPropertyValue("SafeObjectInputStream", - "ListOfSafeObjectsForInputStream"); - List listOfSafeObjects = null; - if (UtilValidate.isNotEmpty(listOfSafeObjectsForInputStream)) { - listOfSafeObjects = Arrays.stream(listOfSafeObjectsForInputStream.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - } else { - listOfSafeObjects = java.util.Arrays.asList("byte\\[\\]", "foo", "SerializationInjector", - "\\[Z","\\[B","\\[S","\\[I","\\[J","\\[F","\\[D","\\[C", - "java..*", "sun.util.calendar..*", "org.apache.ofbiz..*"); - } // "foo" and, "SerializationInjector" are used in UtilObjectTests::testGetObject - try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - SafeObjectInputStream wois = new SafeObjectInputStream(bis, - Thread.currentThread().getContextClassLoader(), - listOfSafeObjects)) {; - + SafeObjectInputStream wois = new SafeObjectInputStream(bis)) { return wois.readObject(); } }