From ce1ffeb8cba326f665ffb7a510858eaeb9abcb51 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 Jun 2023 19:50:45 +0000 Subject: [PATCH] Remove error path for ancient compression detection (#7932) The error message generated by this code path refers to Elasticsearch version 2.0.0.beta1, which is likely to cause confusion with the OpenSearch 2.x line if it were ever to be encountered. The ES2 version is so old that I don't think we need any special handling here and can just fall back to the default "not xcontent" error message. Signed-off-by: Andrew Ross (cherry picked from commit 4592d7c6cfb9a06ff9800ea9573eb72f735c2138) Signed-off-by: github-actions[bot] --- .../common/compress/CompressorFactory.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java b/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java index 1d8f2dcec709a..23a8cac349bd2 100644 --- a/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java +++ b/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java @@ -35,7 +35,6 @@ import org.opensearch.common.Nullable; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Objects; @@ -73,22 +72,13 @@ public static Compressor compressor(BytesReference bytes) { return ZSTD_COMPRESSOR; } - XContentType contentType = XContentHelper.xContentType(bytes); - if (contentType == null) { - if (isAncient(bytes)) { - throw new IllegalStateException("unsupported compression: index was created before v2.0.0.beta1 and wasn't upgraded?"); - } + if (XContentHelper.xContentType(bytes) == null) { throw new NotXContentException("Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"); } return null; } - /** true if the bytes were compressed with LZF*/ - private static boolean isAncient(BytesReference bytes) { - return bytes.length() >= 3 && bytes.get(0) == 'Z' && bytes.get(1) == 'V' && (bytes.get(2) == 0 || bytes.get(2) == 1); - } - /** * Uncompress the provided data, data can be detected as compressed using {@link #isCompressed(BytesReference)}. */