/** * Convert the specified throwables into a serialzable array. If * any of the nested throwables cannot be serialized, they will * be converted into a Exception with the original message. */ public static Throwable[] replaceNestedThrowables(Throwable[] nested) { if (nested == null || nested.length == 0) return nested; if (isSerializable(nested)) return nested; Throwable[] newNested = new Throwable[nested.length]; for (int i = 0; i < nested.length; i++) { if (isSerializable(nested[i])) newNested[i] = nested[i]; else // guard against a nasty null in the array by using valueOf // instead of toString to prevent throwing yet another // exception newNested[i] = new Exception(String.valueOf(nested[i])); } return newNested; }
/** * Convert the specified throwables into a serialzable array. If * any of the nested throwables cannot be serialized, they will * be converted into a Exception with the original message. */ public static Throwable[] replaceNestedThrowables(Throwable[] nested) { if (nested == null || nested.length == 0) return nested; if (isSerializable(nested)) return nested; Throwable[] newNested = new Throwable[nested.length]; for (int i = 0; i < nested.length; i++) { if (isSerializable(nested[i])) newNested[i] = nested[i]; else // guard against a nasty null in the array by using valueOf // instead of toString to prevent throwing yet another // exception newNested[i] = new Exception(String.valueOf(nested[i])); } return newNested; }
/** * Convert the specified throwables into a serialzable array. If * any of the nested throwables cannot be serialized, they will * be converted into a Exception with the original message. */ public static Throwable[] replaceNestedThrowables(Throwable[] nested) { if (nested == null || nested.length == 0) return nested; if (isSerializable(nested)) return nested; Throwable[] newNested = new Throwable[nested.length]; for (int i = 0; i < nested.length; i++) { if (isSerializable(nested[i])) newNested[i] = nested[i]; else // guard against a nasty null in the array by using valueOf // instead of toString to prevent throwing yet another // exception newNested[i] = new Exception(String.valueOf(nested[i])); } return newNested; }
/** * Convert the specified throwables into a serialzable array. If * any of the nested throwables cannot be serialized, they will * be converted into a Exception with the original message. */ public static Throwable[] replaceNestedThrowables(Throwable[] nested) { if (nested == null || nested.length == 0) return nested; if (isSerializable(nested)) return nested; Throwable[] newNested = new Throwable[nested.length]; for (int i = 0; i < nested.length; i++) { if (isSerializable(nested[i])) newNested[i] = nested[i]; else // guard against a nasty null in the array by using valueOf // instead of toString to prevent throwing yet another // exception newNested[i] = new Exception(String.valueOf(nested[i])); } return newNested; }
/** * Convert the specified throwables into a serialzable array. If * any of the nested throwables cannot be serialized, they will * be converted into a Exception with the original message. */ public static Throwable[] replaceNestedThrowables(Throwable[] nested) { if (nested == null || nested.length == 0) return nested; if (isSerializable(nested)) return nested; Throwable[] newNested = new Throwable[nested.length]; for (int i = 0; i < nested.length; i++) { if (isSerializable(nested[i])) newNested[i] = nested[i]; else // guard against a nasty null in the array by using valueOf // instead of toString to prevent throwing yet another // exception newNested[i] = new Exception(String.valueOf(nested[i])); } return newNested; }
/** * Convert the specified failed object into a serializable * object for when we are serializing an Exception. It will * try the following: * <ul> * <li>if the object can be serialized, return the object itself</li> * <li>if the object has a serializable oid, return the oid</li> * <li>if the object has a non-serializable oid, return the oid's * toString and the object class</li> * <li>return the object's toString</li> * </ul> * * @param ob the object to convert * @return some serialized representation of the object */ public static Object replaceFailedObject(Object ob) { if (ob == null) return null; if (isSerializable(ob)) return ob; // don't take oid of new objects since it can cause a flush if auto-inc // and the id is meaningless anyway Object oid = getObjectId(ob); if (oid != null && isSerializable(oid)) return oid; // last ditch: stringify the object return toString(ob); }
/** * Convert the specified failed object into a serializable * object for when we are serializing an Exception. It will * try the following: * <ul> * <li>if the object can be serialized, return the object itself</li> * <li>if the object has a serializable oid, return the oid</li> * <li>if the object has a non-serializable oid, return the oid's * toString and the object class</li> * <li>return the object's toString</li> * </ul> * * @param ob the object to convert * @return some serialized representation of the object */ public static Object replaceFailedObject(Object ob) { if (ob == null) return null; if (isSerializable(ob)) return ob; // don't take oid of new objects since it can cause a flush if auto-inc // and the id is meaningless anyway Object oid = getObjectId(ob); if (oid != null && isSerializable(oid)) return oid; // last ditch: stringify the object return toString(ob); }
/** * Convert the specified failed object into a serializable * object for when we are serializing an Exception. It will * try the following: * <ul> * <li>if the object can be serialized, return the object itself</li> * <li>if the object has a serializable oid, return the oid</li> * <li>if the object has a non-serializable oid, return the oid's * toString and the object class</li> * <li>return the object's toString</li> * </ul> * * @param ob the object to convert * @return some serialized representation of the object */ public static Object replaceFailedObject(Object ob) { if (ob == null) return null; if (isSerializable(ob)) return ob; // don't take oid of new objects since it can cause a flush if auto-inc // and the id is meaningless anyway Object oid = getObjectId(ob); if (oid != null && isSerializable(oid)) return oid; // last ditch: stringify the object return toString(ob); }
/** * Convert the specified failed object into a serializable * object for when we are serializing an Exception. It will * try the following: * <ul> * <li>if the object can be serialized, return the object itself</li> * <li>if the object has a serializable oid, return the oid</li> * <li>if the object has a non-serializable oid, return the oid's * toString and the object class</li> * <li>return the object's toString</li> * </ul> * * @param ob the object to convert * @return some serialized representation of the object */ public static Object replaceFailedObject(Object ob) { if (ob == null) return null; if (isSerializable(ob)) return ob; // don't take oid of new objects since it can cause a flush if auto-inc // and the id is meaningless anyway Object oid = getObjectId(ob); if (oid != null && isSerializable(oid)) return oid; // last ditch: stringify the object return toString(ob); }
/** * Convert the specified failed object into a serializable * object for when we are serializing an Exception. It will * try the following: * <ul> * <li>if the object can be serialized, return the object itself</li> * <li>if the object has a serializable oid, return the oid</li> * <li>if the object has a non-serializable oid, return the oid's * toString and the object class</li> * <li>return the object's toString</li> * </ul> * * @param ob the object to convert * @return some serialized representation of the object */ public static Object replaceFailedObject(Object ob) { if (ob == null) return null; if (isSerializable(ob)) return ob; // don't take oid of new objects since it can cause a flush if auto-inc // and the id is meaningless anyway Object oid = getObjectId(ob); if (oid != null && isSerializable(oid)) return oid; // last ditch: stringify the object return toString(ob); }