Define efficient serialization proxies
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / PurgeLocalHistoryPayload.java
index 8d9a8d217a67e201dda8c8f9ba9f705ac939557c..d440910943d213e57cd45037e29593bec864c130 100644 (file)
@@ -50,6 +50,7 @@ public final class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload<
 
     private static final Logger LOG = LoggerFactory.getLogger(PurgeLocalHistoryPayload.class);
     private static final long serialVersionUID = 1L;
+    private static final int PROXY_SIZE = externalizableProxySize(Proxy::new);
 
     PurgeLocalHistoryPayload(final LocalHistoryIdentifier historyId, final byte[] serialized) {
         super(historyId, serialized);
@@ -63,7 +64,7 @@ public final class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload<
         } catch (IOException e) {
             // This should never happen
             LOG.error("Failed to serialize {}", historyId, e);
-            throw new RuntimeException("Failed to serialize " + historyId, e);
+            throw new IllegalStateException("Failed to serialize " + historyId, e);
         }
         return new PurgeLocalHistoryPayload(historyId, out.toByteArray());
     }
@@ -72,4 +73,9 @@ public final class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload<
     protected Proxy externalizableProxy(final byte[] serialized) {
         return new Proxy(serialized);
     }
+
+    @Override
+    protected int externalizableProxySize() {
+        return PROXY_SIZE;
+    }
 }