From f96d0e31503a64e7648c7f78f9b9db6ae4ad9cf7 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 29 Dec 2021 21:53:50 +0100 Subject: Checksum: Convert 0-sized checksums to all-zeros checksums. Change-Id: Ia2429edafcdc93aad01310f66f489c3dd54ec365 --- jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java index 705e27c..ce5f9b0 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java @@ -16,6 +16,10 @@ public record Checksum(ByteString byteString) { private static final Decoder DECODER = ByteString.decoder().map(Checksum::new); public Checksum { + if (byteString.size() == 0) { + byteString = zero().byteString; + } + if (byteString.size() != SIZE) { throw new IllegalArgumentException( "attempted to construct Checksum of length %d (expected: %d)" -- cgit v1.2.3