Skip to content

Commit

Permalink
Remove is_error invokation on function return with valid negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
jklamer committed Sep 25, 2024
1 parent befc81b commit 852deaa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/io/airlift/compress/v3/zstd/ZstdNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private ZstdNative() {}
// TODO should we just hardcode this to 3?
public static final int DEFAULT_COMPRESSION_LEVEL;

private static final long ZSTD_CONTENTSIZE_UNKNOWN;

static {
NativeLoader.Symbols<MethodHandles> symbols = NativeLoader.loadSymbols("zstd", MethodHandles.class, lookup());
LINKAGE_ERROR = symbols.linkageError();
Expand All @@ -74,6 +76,7 @@ private ZstdNative() {}
else {
DEFAULT_COMPRESSION_LEVEL = -1;
}
ZSTD_CONTENTSIZE_UNKNOWN = -1L;
}

public static boolean isEnabled()
Expand Down Expand Up @@ -154,7 +157,7 @@ public static long decompressedLength(MemorySegment compressed, long compressedL
throw new Error("Unexpected exception", e);
}

if (isError(result)) {
if (ZSTD_CONTENTSIZE_UNKNOWN != result && result < 0) {
throw new IllegalArgumentException("Unknown error occurred during decompression: " + getErrorName(result));
}
return result;
Expand Down

0 comments on commit 852deaa

Please sign in to comment.