diff options
Diffstat (limited to 'jgvariant-ostree/src')
3 files changed, 17 insertions, 15 deletions
diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/ByteString.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/ByteString.java index 3a8185c..cfe3635 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/ByteString.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/ByteString.java @@ -10,6 +10,7 @@ import java.util.Base64; import java.util.HexFormat; import java.util.stream.IntStream; import java.util.stream.Stream; +import org.jetbrains.annotations.Nullable; /** * A wrapper for a {@code byte[]} that implements {@link #equals(Object)}, {@link #hashCode()}, and @@ -31,7 +32,7 @@ public record ByteString(byte[] bytes) { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return (o instanceof ByteString byteString) && Arrays.equals(bytes, byteString.bytes); } diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaSuperblock.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaSuperblock.java index 52b970f..50da203 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaSuperblock.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaSuperblock.java @@ -70,20 +70,20 @@ public record DeltaSuperblock( Decoder.ofByteArray().map(DeltaSuperblock::parseDeltaNameList), Decoder.ofArray(DeltaMetaEntry.decoder()).withByteOrder(ByteOrder.LITTLE_ENDIAN), Decoder.ofArray(DeltaFallback.decoder()).withByteOrder(ByteOrder.LITTLE_ENDIAN)) - .map( - deltaSuperblock -> { - // Fix up the endianness of the 'entries' and 'fallbacks' fields, which have - // unspecified byte order. - var endiannessMetadatum = - deltaSuperblock.metadata().fields().get("ostree.endianness"); - if (endiannessMetadatum != null - && endiannessMetadatum.value() instanceof Byte endiannessByte - && endiannessByte == (byte) 'B') { - return deltaSuperblock.byteSwapped(); - } else { - return deltaSuperblock; - } - }); + .map(DeltaSuperblock::byteSwappedIfBigEndian); + + private DeltaSuperblock byteSwappedIfBigEndian() { + // Fix up the endianness of the 'entries' and 'fallbacks' fields, which have + // unspecified byte order. + var endiannessMetadatum = metadata().fields().get("ostree.endianness"); + if (endiannessMetadatum != null + && endiannessMetadatum.value() instanceof Byte endiannessByte + && endiannessByte == (byte) 'B') { + return byteSwapped(); + } else { + return this; + } + } private DeltaSuperblock byteSwapped() { return new DeltaSuperblock( diff --git a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java index 5c1dd79..d8ad271 100644 --- a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java +++ b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java @@ -17,6 +17,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; @TestWithResources +@SuppressWarnings("initialization.field.uninitialized") class OstreeDecoderTest { @GivenBinaryResource("/ostree/summary") |