diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2021-12-29 21:53:50 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2021-12-29 21:53:50 +0100 |
commit | f96d0e31503a64e7648c7f78f9b9db6ae4ad9cf7 (patch) | |
tree | 5fc40e065833d5c23ee845b2df85e09f84129ac9 /jgvariant-ostree | |
parent | 05114647f0cd37fd09d344a088d5c57c4ac68a32 (diff) |
Checksum: Convert 0-sized checksums to all-zeros checksums.
Change-Id: Ia2429edafcdc93aad01310f66f489c3dd54ec365
Diffstat (limited to 'jgvariant-ostree')
-rw-r--r-- | jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java | 4 |
1 files changed, 4 insertions, 0 deletions
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<Checksum> 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)" |