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);
}
- public static PurgeLocalHistoryPayload create(final LocalHistoryIdentifier historyId) {
- final ByteArrayDataOutput out = ByteStreams.newDataOutput();
+ public static PurgeLocalHistoryPayload create(final LocalHistoryIdentifier historyId,
+ final int initialSerializedBufferCapacity) {
+ final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
try {
historyId.writeTo(out);
} 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());
}
protected Proxy externalizableProxy(final byte[] serialized) {
return new Proxy(serialized);
}
+
+ @Override
+ protected int externalizableProxySize() {
+ return PROXY_SIZE;
+ }
}