Skip to content

Commit 0126bd1

Browse files
alexey-ivanov-esmartijnvg
authored andcommitted
Remove occurrences of the Java annotation @UpdateForV9 (ES-9378) (elastic#119105)
Restore contentTypeVersion check in RestCompatibleVersionHelper which was commented out when RestApiVersion.V_9 was introduced, update tests to work correctly with v9 version and remove @UpdateForV9 annotation that is no longer applicable
1 parent 44a8cf9 commit 0126bd1

File tree

5 files changed

+14
-25
lines changed

5 files changed

+14
-25
lines changed

server/src/main/java/org/elasticsearch/rest/RestCompatibleVersionHelper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.ElasticsearchStatusException;
1212
import org.elasticsearch.core.Nullable;
1313
import org.elasticsearch.core.RestApiVersion;
14-
import org.elasticsearch.core.UpdateForV9;
1514
import org.elasticsearch.xcontent.MediaType;
1615
import org.elasticsearch.xcontent.ParsedMediaType;
1716

@@ -27,7 +26,6 @@ class RestCompatibleVersionHelper {
2726
/**
2827
* @return The requested API version, or {@link Optional#empty()} if there was no explicit version in the request.
2928
*/
30-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
3129
static Optional<RestApiVersion> getCompatibleVersion(
3230
@Nullable ParsedMediaType acceptHeader,
3331
@Nullable ParsedMediaType contentTypeHeader,
@@ -52,8 +50,7 @@ static Optional<RestApiVersion> getCompatibleVersion(
5250
if (hasContent) {
5351

5452
// content-type version must be current or prior
55-
// This can be uncommented once all references to RestApiVersion.V_7 are removed
56-
/*if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) {
53+
if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) {
5754
throw new ElasticsearchStatusException(
5855
"Content-Type version must be either version {} or {}, but found {}. Content-Type={}",
5956
RestStatus.BAD_REQUEST,
@@ -62,7 +59,7 @@ static Optional<RestApiVersion> getCompatibleVersion(
6259
contentTypeVersion,
6360
contentTypeHeader
6461
);
65-
}*/
62+
}
6663
// if both accept and content-type are sent, the version must match
6764
if (contentTypeVersion != acceptVersion) {
6865
throw new ElasticsearchStatusException(

server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import org.elasticsearch.cluster.metadata.IndexMetadata;
1414
import org.elasticsearch.cluster.metadata.Metadata;
1515
import org.elasticsearch.common.settings.Settings;
16-
import org.elasticsearch.core.UpdateForV9;
1716
import org.elasticsearch.index.IndexVersion;
17+
import org.elasticsearch.index.IndexVersions;
1818
import org.elasticsearch.indices.SystemIndexDescriptor;
1919
import org.elasticsearch.indices.SystemIndexDescriptorUtils;
2020
import org.elasticsearch.indices.SystemIndices;
@@ -31,7 +31,8 @@
3131
public class TransportGetFeatureUpgradeStatusActionTests extends ESTestCase {
3232

3333
public static String TEST_SYSTEM_INDEX_PATTERN = ".test*";
34-
private static final IndexVersion TEST_OLD_VERSION = IndexVersion.fromId(6000099);
34+
// Version just before MINIMUM_COMPATIBLE in order to check that UpgradeStatus.MIGRATION_NEEDED is set correctly
35+
private static final IndexVersion TEST_OLD_VERSION = IndexVersion.fromId(IndexVersions.MINIMUM_COMPATIBLE.id() - 1);
3536
private static final ClusterState CLUSTER_STATE = getClusterState();
3637
private static final SystemIndices.Feature FEATURE = getFeature();
3738

@@ -85,8 +86,6 @@ private static ClusterState getClusterState() {
8586
.numberOfReplicas(0)
8687
.build();
8788

88-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
89-
// Once we start testing 9.x, we should update this test to use a 7.x "version created"
9089
IndexMetadata indexMetadata2 = IndexMetadata.builder(".test-index-2")
9190
.settings(Settings.builder().put("index.version.created", TEST_OLD_VERSION).build())
9291
.numberOfShards(1)

server/src/test/java/org/elasticsearch/common/xcontent/CompatibleNamedXContentRegistryTests.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.Version;
1313
import org.elasticsearch.common.bytes.BytesReference;
1414
import org.elasticsearch.core.RestApiVersion;
15-
import org.elasticsearch.core.UpdateForV9;
1615
import org.elasticsearch.rest.RestRequest;
1716
import org.elasticsearch.test.ESTestCase;
1817
import org.elasticsearch.test.rest.FakeRestRequest;
@@ -116,8 +115,6 @@ public static NewSubObject parse(XContentParser parser) {
116115
}
117116
}
118117

119-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
120-
@AwaitsFix(bugUrl = "this can be re-enabled once our rest api version is bumped to V_9")
121118
public void testNotCompatibleRequest() throws IOException {
122119
NamedXContentRegistry registry = new NamedXContentRegistry(
123120
List.of(

server/src/test/java/org/elasticsearch/rest/RestCompatibleVersionHelperTests.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,15 @@ public void testObsoleteVersion() {
210210
assertThat(
211211
e.getMessage(),
212212
equalTo(
213-
"A compatible version is required on both Content-Type and Accept headers if either one has requested a "
214-
+ "compatible version and the compatible versions must match. "
215-
+ "Accept="
216-
+ acceptHeader(PREVIOUS_VERSION)
217-
+ ", Content-Type="
218-
+ contentTypeHeader(OBSOLETE_VERSION)
213+
"Content-Type version must be either version "
214+
+ CURRENT_VERSION
215+
+ " or "
216+
+ PREVIOUS_VERSION
217+
+ ", but found "
218+
+ OBSOLETE_VERSION
219+
+ ". "
220+
+ "Content-Type="
221+
+ acceptHeader(OBSOLETE_VERSION)
219222
)
220223
);
221224
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.cluster.node.DiscoveryNode;
1313
import org.elasticsearch.common.io.stream.StreamInput;
1414
import org.elasticsearch.common.io.stream.StreamOutput;
15-
import org.elasticsearch.core.UpdateForV9;
1615
import org.elasticsearch.transport.TransportRequest;
1716
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1817

@@ -32,19 +31,13 @@ private NodesDeprecationCheckAction() {
3231
super(NAME);
3332
}
3433

35-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // this can be replaced with TransportRequest.Empty in v9
3634
public static class NodeRequest extends TransportRequest {
3735

3836
public NodeRequest() {}
3937

4038
public NodeRequest(StreamInput in) throws IOException {
4139
super(in);
4240
}
43-
44-
@Override
45-
public void writeTo(StreamOutput out) throws IOException {
46-
super.writeTo(out);
47-
}
4841
}
4942

5043
public static class NodeResponse extends BaseNodeResponse {

0 commit comments

Comments
 (0)