Răsfoiți Sursa

Fix BWC after backport of #65564 (#65727)

Relates #65564
Relates #65689
David Turner 4 ani în urmă
părinte
comite
01c343f3e2

+ 2 - 2
build.gradle

@@ -175,8 +175,8 @@ tasks.register("verifyVersions") {
  * after the backport of the backcompat code is complete.
  */
 
-boolean bwc_tests_enabled = false
-final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/65689" /* place a PR link here when committing bwc changes */
+boolean bwc_tests_enabled = true
+final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
 if (bwc_tests_enabled == false) {
   if (bwc_tests_disabled_issue.isEmpty()) {
     throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

+ 14 - 23
server/src/main/java/org/elasticsearch/index/shard/IndexLongFieldRange.java

@@ -34,8 +34,6 @@ import java.util.List;
 import java.util.Objects;
 import java.util.stream.IntStream;
 
-import static org.elasticsearch.index.shard.ShardLongFieldRange.LONG_FIELD_RANGE_VERSION_INTRODUCED;
-
 /**
  * Class representing an (inclusive) range of {@code long} values in a field in an index which may comprise multiple shards. This
  * information is accumulated shard-by-shard, and we keep track of which shards are represented in this value. Only once all shards are
@@ -120,33 +118,26 @@ public class IndexLongFieldRange implements Writeable, ToXContentFragment {
 
     @Override
     public void writeTo(StreamOutput out) throws IOException {
-        if (out.getVersion().onOrAfter(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
-            if (this == NO_SHARDS) {
-                out.writeByte(WIRE_TYPE_NO_SHARDS);
-            } else if (this == UNKNOWN) {
-                out.writeByte(WIRE_TYPE_UNKNOWN);
-            } else if (this == EMPTY) {
-                out.writeByte(WIRE_TYPE_EMPTY);
+        if (this == NO_SHARDS) {
+            out.writeByte(WIRE_TYPE_NO_SHARDS);
+        } else if (this == UNKNOWN) {
+            out.writeByte(WIRE_TYPE_UNKNOWN);
+        } else if (this == EMPTY) {
+            out.writeByte(WIRE_TYPE_EMPTY);
+        } else {
+            out.writeByte(WIRE_TYPE_OTHER);
+            if (shards == null) {
+                out.writeBoolean(false);
             } else {
-                out.writeByte(WIRE_TYPE_OTHER);
-                if (shards == null) {
-                    out.writeBoolean(false);
-                } else {
-                    out.writeBoolean(true);
-                    out.writeVIntArray(shards);
-                }
-                out.writeZLong(min);
-                out.writeZLong(max);
+                out.writeBoolean(true);
+                out.writeVIntArray(shards);
             }
+            out.writeZLong(min);
+            out.writeZLong(max);
         }
     }
 
     public static IndexLongFieldRange readFrom(StreamInput in) throws IOException {
-        if (in.getVersion().before(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
-            // conservative treatment for BWC
-            return UNKNOWN;
-        }
-
         final byte type = in.readByte();
         switch (type) {
             case WIRE_TYPE_NO_SHARDS:

+ 8 - 18
server/src/main/java/org/elasticsearch/index/shard/ShardLongFieldRange.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.index.shard;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
 import org.elasticsearch.common.io.stream.Writeable;
@@ -32,8 +31,6 @@ import java.util.Objects;
  */
 public class ShardLongFieldRange implements Writeable {
 
-    public static final Version LONG_FIELD_RANGE_VERSION_INTRODUCED = Version.V_8_0_0;
-
     /**
      * Sentinel value indicating an empty range, for instance because the field is missing or has no values.
      */
@@ -91,11 +88,6 @@ public class ShardLongFieldRange implements Writeable {
     private static final byte WIRE_TYPE_EMPTY = (byte)2;
 
     public static ShardLongFieldRange readFrom(StreamInput in) throws IOException {
-        if (in.getVersion().before(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
-            // conservative treatment for BWC
-            return UNKNOWN;
-        }
-
         final byte type = in.readByte();
         switch (type) {
             case WIRE_TYPE_UNKNOWN:
@@ -111,16 +103,14 @@ public class ShardLongFieldRange implements Writeable {
 
     @Override
     public void writeTo(StreamOutput out) throws IOException {
-        if (out.getVersion().onOrAfter(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
-            if (this == UNKNOWN) {
-                out.writeByte(WIRE_TYPE_UNKNOWN);
-            } else if (this == EMPTY) {
-                out.writeByte(WIRE_TYPE_EMPTY);
-            } else {
-                out.writeByte(WIRE_TYPE_OTHER);
-                out.writeZLong(min);
-                out.writeZLong(max);
-            }
+        if (this == UNKNOWN) {
+            out.writeByte(WIRE_TYPE_UNKNOWN);
+        } else if (this == EMPTY) {
+            out.writeByte(WIRE_TYPE_EMPTY);
+        } else {
+            out.writeByte(WIRE_TYPE_OTHER);
+            out.writeZLong(min);
+            out.writeZLong(max);
         }
     }
 

+ 1 - 2
server/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java

@@ -532,8 +532,7 @@ public class ShardStateActionTests extends ESTestCase {
             assertThat(deserialized.allocationId, equalTo(allocationId));
             assertThat(deserialized.primaryTerm, equalTo(primaryTerm));
             assertThat(deserialized.message, equalTo(message));
-            assertThat(deserialized.timestampMillisRange, version.onOrAfter(ShardLongFieldRange.LONG_FIELD_RANGE_VERSION_INTRODUCED) ?
-                    equalTo(timestampMillisRange) : sameInstance(ShardLongFieldRange.UNKNOWN));
+            assertThat(deserialized.timestampMillisRange, equalTo(timestampMillisRange));
         }
     }