Fix InvalidRangeConstraintException serializability 12/95212/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Feb 2021 17:15:49 +0000 (18:15 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Feb 2021 17:16:19 +0000 (18:16 +0100)
Use an ImmutableRangeSet to guarantee the exception can be serialized.

Change-Id: I7455eba1df008c0456377e199b96bf91eb929f44
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-ri/src/main/java/org/opendaylight/yangtools/yang/model/ri/type/InvalidRangeConstraintException.java

index 381d7f1b66f4989090a1e5355bc0f8d2da007c39..a52670a77234c2de59c7af73f13b1d2f88c21936 100644 (file)
@@ -7,20 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.model.ri.type;
 
-import static java.util.Objects.requireNonNull;
-
 import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.RangeSet;
 
 @Beta
 public class InvalidRangeConstraintException extends IllegalArgumentException {
     private static final long serialVersionUID = 1L;
 
-    private final RangeSet<?> offendingRangeConstraint;
+    private final ImmutableRangeSet<?> offendingRangeConstraint;
 
     protected InvalidRangeConstraintException(final RangeSet<?> offendingConstraint, final String message) {
         super(message);
-        this.offendingRangeConstraint = requireNonNull(offendingConstraint);
+        this.offendingRangeConstraint = ImmutableRangeSet.copyOf(offendingConstraint);
     }
 
     public InvalidRangeConstraintException(final RangeSet<?> offendingConstraint, final String format,
@@ -28,7 +27,7 @@ public class InvalidRangeConstraintException extends IllegalArgumentException {
         this(offendingConstraint, String.format(format, args));
     }
 
-    public RangeSet<?> getOffendingRanges() {
+    public final RangeSet<?> getOffendingRanges() {
         return offendingRangeConstraint;
     }
 }