From 2e87c36ca046d22fda07caccf9ab0988f70bdb40 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 11 Nov 2014 11:41:07 -0800 Subject: [PATCH] Making this class serializable The use case that led me here was to use this from workflow which relies primarily on Java serialization --- .../main/java/jenkins/model/CauseOfInterruption.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/jenkins/model/CauseOfInterruption.java b/core/src/main/java/jenkins/model/CauseOfInterruption.java index 469f3e1a29..dbec0221ac 100644 --- a/core/src/main/java/jenkins/model/CauseOfInterruption.java +++ b/core/src/main/java/jenkins/model/CauseOfInterruption.java @@ -31,6 +31,8 @@ import hudson.model.User; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; +import java.io.Serializable; + /** * Records why an {@linkplain Executor#interrupt() executor is interrupted}. * @@ -44,13 +46,16 @@ import org.kohsuke.stapler.export.ExportedBean; * Two {@link CauseOfInterruption}s that are {@linkplain Object#equals(Object) equal} will get * merged together. * + *

Persistence

+ * The implementation should be serializable both in Java serialization and XStream. + * * @author Kohsuke Kawaguchi * @since 1.425 * @see Executor#interrupt(Result, CauseOfInterruption...) * @see InterruptedBuildAction */ @ExportedBean -public abstract class CauseOfInterruption { +public abstract class CauseOfInterruption implements Serializable { /** * Human readable description of why the build is cancelled. */ @@ -103,5 +108,9 @@ public abstract class CauseOfInterruption { public int hashCode() { return user.hashCode(); } + + private static final long serialVersionUID = 1L; } + + private static final long serialVersionUID = 1L; } -- GitLab