Use SSv1 during writeout 26/102126/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 07:45:08 +0000 (09:45 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 08:57:28 +0000 (10:57 +0200)
Make sure we are not dependent on SingletonSet hierarchy in
serialization writeout path.

Change-Id: I7b602f166bccc418ea27af0b887f5868fadbf9e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0fc692ac97b7a899750bc4eb6559dacdabdc0433)

common/util/src/main/java/org/opendaylight/yangtools/util/SingletonSet.java

index 7097ec29d09a5efc71eaae02e977c76a365825f2..c545692a173bca12f84d288851a0b69937d23911 100644 (file)
@@ -165,6 +165,11 @@ public abstract class SingletonSet<E> implements Set<E>, Immutable, Serializable
         return obj == this || obj instanceof Set<?> other && other.size() == 1 && otherContains(other);
     }
 
+    @Serial
+    final Object writeReplace() {
+        return new SSv1(getElement());
+    }
+
     @SuppressFBWarnings(value = "DCN_NULLPOINTER_EXCEPTION",
         justification = "https://github.com/spotbugs/spotbugs/issues/1954")
     private boolean otherContains(final @NonNull Collection<?> other) {