+ static final class Simple extends CommitTransactionPayload {
+ @java.io.Serial
+ private static final long serialVersionUID = 1L;
+
+ private final byte[] serialized;
+
+ Simple(final byte[] serialized) {
+ this.serialized = requireNonNull(serialized);
+ }
+
+ @Override
+ public int size() {
+ return serialized.length;
+ }
+
+ @Override
+ DataInput newDataInput() {
+ return ByteStreams.newDataInput(serialized);
+ }
+
+ @Override
+ void writeBytes(final ObjectOutput out) throws IOException {
+ out.write(serialized);
+ }
+ }
+
+ static final class Chunked extends CommitTransactionPayload {
+ @java.io.Serial
+ private static final long serialVersionUID = 1L;
+
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "Handled via serialization proxy")
+ private final ChunkedByteArray source;
+
+ Chunked(final ChunkedByteArray source) {
+ this.source = requireNonNull(source);
+ }
+
+ @Override
+ void writeBytes(final ObjectOutput out) throws IOException {
+ source.copyTo(out);
+ }
+
+ @Override
+ public int size() {
+ return source.size();
+ }
+
+ @Override
+ DataInput newDataInput() {
+ return new DataInputStream(source.openStream());
+ }
+ }
+
+ // Exists to break initialization dependency between CommitTransactionPayload/Simple/Proxy
+ private static final class ProxySizeHolder {
+ static final int PROXY_SIZE = SerializationUtils.serialize(new CT(new Simple(new byte[0]))).length;
+
+ private ProxySizeHolder() {
+ // Hidden on purpose
+ }