diff --git a/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java b/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java index acb6a916c0..69499c5e60 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java @@ -22,14 +22,22 @@ public final class MissingNode extends ValueNode { + private static final long serialVersionUID = 1L; + private final static MissingNode instance = new MissingNode(); /** *
- * NOTE: visibility raised to `protected` in 2.9.3 to allow custom subtypes. + * NOTE: visibility raised to `protected` in 2.9.3 to allow custom subtypes + * (which may not be greatest idea ever to have but was requested) */ protected MissingNode() { } + // To support JDK serialization, recovery of Singleton instance + protected Object readResolve() { + return instance; + } + @Override public boolean isMissingNode() { return true; diff --git a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java index 1a222433bc..cb8f288659 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java @@ -15,6 +15,8 @@ public final class NullNode { // // Just need a fly-weight singleton + private static final long serialVersionUID = 1L; + public final static NullNode instance = new NullNode(); /** @@ -23,6 +25,11 @@ public final class NullNode */ protected NullNode() { } + // To support JDK serialization, recovery of Singleton instance + protected Object readResolve() { + return instance; + } + public static NullNode getInstance() { return instance; } @Override