diff --git a/src/java/org/apache/commons/lang/exception/ContextedException.java b/src/java/org/apache/commons/lang/exception/ContextedException.java index 6885ae855..d9c4c9dcb 100644 --- a/src/java/org/apache/commons/lang/exception/ContextedException.java +++ b/src/java/org/apache/commons/lang/exception/ContextedException.java @@ -16,7 +16,6 @@ */ package org.apache.commons.lang.exception; -import java.io.Serializable; import java.util.Set; /** @@ -141,15 +140,13 @@ public class ContextedException extends Exception implements ExceptionContext { * the problem. For the information to be meaningful, the value passed * should have a reasonable toString() implementation. *
- * Note: If the value provided isn't Serializable, one solution would be - * to provide its toString() if it has a meaningful implementation or - * individual properties of the value object instead. + * Note: This exception is only serializable if the object added is serializable. * * @param label a textual label associated with information, null not recommended * @param value information needed to understand exception, may be null * @return this, for method chaining */ - public ContextedException addLabeledValue(String label, Serializable value) { + public ContextedException addLabeledValue(String label, Object value) { exceptionContext.addLabeledValue(label, value); return this; } @@ -160,7 +157,7 @@ public class ContextedException extends Exception implements ExceptionContext { * @param label the label to get the contextual value for, may be null * @return the contextual value associated with the label, may be null */ - public Serializable getLabeledValue(String label) { + public Object getLabeledValue(String label) { return exceptionContext.getLabeledValue(label); } diff --git a/src/java/org/apache/commons/lang/exception/ContextedRuntimeException.java b/src/java/org/apache/commons/lang/exception/ContextedRuntimeException.java index 46575d1d4..41ea0899e 100644 --- a/src/java/org/apache/commons/lang/exception/ContextedRuntimeException.java +++ b/src/java/org/apache/commons/lang/exception/ContextedRuntimeException.java @@ -16,7 +16,6 @@ */ package org.apache.commons.lang.exception; -import java.io.Serializable; import java.util.Set; /** @@ -142,15 +141,13 @@ public class ContextedRuntimeException extends Exception implements ExceptionCon * the problem. For the information to be meaningful, the value passed * should have a reasonable toString() implementation. *
- * Note: If the value provided isn't Serializable, one solution would be - * to provide its toString() if it has a meaningful implementation or - * individual properties of the value object instead. + * Note: This exception is only serializable if the object added is serializable. * * @param label a textual label associated with information, null not recommended * @param value information needed to understand exception, may be null * @return this, for method chaining */ - public ContextedRuntimeException addLabeledValue(String label, Serializable value) { + public ContextedRuntimeException addLabeledValue(String label, Object value) { exceptionContext.addLabeledValue(label, value); return this; } @@ -161,7 +158,7 @@ public class ContextedRuntimeException extends Exception implements ExceptionCon * @param label the label to get the contextual value for, may be null * @return the contextual value associated with the label, may be null */ - public Serializable getLabeledValue(String label) { + public Object getLabeledValue(String label) { return exceptionContext.getLabeledValue(label); } diff --git a/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java b/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java index 1153a92f1..7a4caa9ab 100644 --- a/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java +++ b/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java @@ -25,16 +25,19 @@ import org.apache.commons.lang.SystemUtils; /** * Default implementation of the context storing the label-value pairs for contexted exceptions. + *
+ * This implementation is serializable, however this is dependent on the values that
+ * are added also being serializable.
*
* @author D. Ashmore
* @since 3.0
*/
-class DefaultExceptionContext implements ExceptionContext {
+class DefaultExceptionContext implements ExceptionContext, Serializable {
/** The serialization version. */
private static final long serialVersionUID = 293747957535772807L;
/** The ordered map storing the label-data pairs. */
- private Map The Method object for Java 1.4 getCause. The Method object for Java 1.4 initCause.
* Public constructor allows an instance of ExceptionUtils
to be created, although that is not