Require exact binary length

This commit is contained in:
Andrea Cavalli 2023-05-22 23:34:08 +02:00
parent 26961125c0
commit dc03d25fdc

View File

@ -65,7 +65,7 @@ public interface SerializerFixedBinaryLength<A> extends Serializer<A> {
var bytes = deserialized.getBytes(StandardCharsets.UTF_8);
out.ensureWritable(bytes.length);
out.write(bytes);
if (bytes.length < getSerializedBinaryLength()) {
if (bytes.length != getSerializedBinaryLength()) {
throw new SerializationException("Fixed serializer with " + getSerializedBinaryLength()
+ " bytes has tried to serialize an element with "
+ bytes.length + " bytes instead");