From e03d4dafcd2fdff3e31a083f2ce7fa50edec8d6a Mon Sep 17 00:00:00 2001 From: Ian Springer Date: Mon, 15 May 2023 22:53:15 -0400 Subject: [PATCH] JAVA-4868 backport: use default compression level for zstd --- .../main/com/mongodb/internal/connection/ZstdCompressor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/driver-core/src/main/com/mongodb/internal/connection/ZstdCompressor.java b/driver-core/src/main/com/mongodb/internal/connection/ZstdCompressor.java index b7b595e032..0d06a1d207 100644 --- a/driver-core/src/main/com/mongodb/internal/connection/ZstdCompressor.java +++ b/driver-core/src/main/com/mongodb/internal/connection/ZstdCompressor.java @@ -27,6 +27,8 @@ import java.util.List; class ZstdCompressor extends Compressor { + private static final int DEFAULT_COMPRESSION_LEVEL = 3; + @Override public String getName() { return "zstd"; @@ -46,7 +48,7 @@ public void compress(final List source, final BsonOutput target) { try { byte[] out = new byte[(int) Zstd.compressBound(uncompressedSize)]; - int compressedSize = (int) Zstd.compress(out, singleByteArraySource, Zstd.maxCompressionLevel()); + int compressedSize = (int) Zstd.compress(out, singleByteArraySource, DEFAULT_COMPRESSION_LEVEL); target.writeBytes(out, 0, compressedSize); } catch (RuntimeException e) { throw new MongoInternalException("Unexpected RuntimeException", e);