Author: doogie
Date: Thu May 3 22:13:11 2012
New Revision: 1333655
URL:
http://svn.apache.org/viewvc?rev=1333655&view=revLog:
OPTIMIZE/FEATURE: Factor getObject into another helper,
getObjectException; the latter doesn't catch any exceptions, and doesn't
log them.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java?rev=1333655&r1=1333654&r2=1333655&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java Thu May 3 22:13:11 2012
@@ -126,36 +126,34 @@ public final class UtilObject {
return size;
}
- /** Deserialize a byte array back to an object */
+ /** Deserialize a byte array back to an object; if there is an error, it is logged, and null is returned. */
public static Object getObject(byte[] bytes) {
Object obj = null;
try {
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- try {
- ObjectInputStream ois = new ObjectInputStream(bis, Thread.currentThread().getContextClassLoader());
- try {
- obj = ois.readObject();
- } catch (ClassNotFoundException e) {
- Debug.logError(e, module);
- } catch (IOException e) {
- Debug.logError(e, module);
- } finally {
- ois.close();
- }
- } catch (IOException e) {
- Debug.logError(e, module);
- } finally {
- bis.close();
- }
+ obj = getObjectException(bytes);
+ } catch (ClassNotFoundException e) {
+ Debug.logError(e, module);
} catch (IOException e) {
- // How could this ever happen? BAIS.close() is listed as
- // throwing the exception, but I don't understand why this
- // is.
Debug.logError(e, module);
}
return obj;
}
+ /** Deserialize a byte array back to an object */
+ public static Object getObjectException(byte[] bytes) throws ClassNotFoundException, IOException {
+ ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
+ try {
+ ObjectInputStream ois = new ObjectInputStream(bis, Thread.currentThread().getContextClassLoader());
+ try {
+ return ois.readObject();
+ } finally {
+ ois.close();
+ }
+ } finally {
+ bis.close();
+ }
+ }
+
public static boolean equalsHelper(Object o1, Object o2) {
if (o1 == o2) {
// handles same-reference, or null