Skip to content

Commit

Permalink
Removed additional usages of Version.CURRENT in strings (#100076)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldematte authored Oct 4, 2023
1 parent 39c04d2 commit 1e98245
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package org.elasticsearch.system.indices;

import org.apache.http.util.EntityUtils;
import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
Expand All @@ -36,7 +35,7 @@ protected Settings restClientSettings() {
public void testCreatingSystemIndex() throws Exception {
ResponseException e = expectThrows(
ResponseException.class,
() -> client().performRequest(new Request("PUT", "/.net-new-system-index-" + Version.CURRENT.major))
() -> client().performRequest(new Request("PUT", "/.net-new-system-index-primary"))
);
assertThat(EntityUtils.toString(e.getResponse().getEntity()), containsString("system"));

Expand All @@ -48,7 +47,7 @@ public void testIndexDoc() throws Exception {
String id = randomAlphaOfLength(4);

ResponseException e = expectThrows(ResponseException.class, () -> {
Request request = new Request("PUT", "/.net-new-system-index-" + Version.CURRENT.major + "/_doc" + id);
Request request = new Request("PUT", "/.net-new-system-index-primary/_doc" + id);
request.setJsonEntity("{}");
client().performRequest(request);
});
Expand Down Expand Up @@ -91,7 +90,7 @@ public void testSearch() throws Exception {
assertThat(EntityUtils.toString(searchResponse.getEntity()), not(containsString(".net-new")));

// direct index search
Request directRequest = new Request("GET", "/.net-new-system-index-" + Version.CURRENT.major + "/_search");
Request directRequest = new Request("GET", "/.net-new-system-index-primary/_search");
directRequest.setJsonEntity("{ \"query\": { \"match_all\": {} } }");
directRequest.addParameter("size", "10000");
ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(directRequest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.system.indices;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.internal.node.NodeClient;
Expand Down Expand Up @@ -76,7 +75,7 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
)
.setOrigin(TASKS_ORIGIN)
.setVersionMetaKey("version")
.setPrimaryIndex(".net-new-system-index-" + Version.CURRENT.major)
.setPrimaryIndex(".net-new-system-index-primary")
.build(),
SystemIndexDescriptor.builder()
.setIndexPattern(INTERNAL_UNMANAGED_INDEX_NAME)
Expand All @@ -99,7 +98,7 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
)
.setOrigin(TASKS_ORIGIN)
.setVersionMetaKey("version")
.setPrimaryIndex(".internal-managed-index-" + Version.CURRENT.major)
.setPrimaryIndex(".internal-managed-index-primary")
.setAliasName(".internal-managed-alias")
.build()
);
Expand All @@ -110,7 +109,6 @@ private static XContentBuilder mappings() {
return jsonBuilder().startObject()
.startObject(SINGLE_MAPPING_NAME)
.startObject("_meta")
.field("version", Version.CURRENT)
.field(SystemIndexDescriptor.VERSION_META_KEY, 1)
.endObject()
.field("dynamic", "strict")
Expand Down Expand Up @@ -155,7 +153,7 @@ public List<Route> routes() {
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
return channel -> client.admin()
.indices()
.create(new CreateIndexRequest(".net-new-system-index-" + Version.CURRENT.major), new RestToXContentListener<>(channel));
.create(new CreateIndexRequest(".net-new-system-index-primary"), new RestToXContentListener<>(channel));
}

@Override
Expand All @@ -177,7 +175,7 @@ public List<Route> routes() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
IndexRequest indexRequest = new IndexRequest(".net-new-system-index-" + Version.CURRENT.major);
IndexRequest indexRequest = new IndexRequest(".net-new-system-index-primary");
indexRequest.source(request.requiredContent(), request.getXContentType());
indexRequest.id(request.param("id"));
indexRequest.setRefreshPolicy(request.param("refresh"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ static Pattern getPatternWithoutSemanticVersion() {
* three-digit number with various standard warn codes specified. The warn code 299 is apt for our purposes as it represents a
* miscellaneous persistent warning (can be presented to a human, or logged, and must not be removed by a cache). The warn-agent is an
* arbitrary token; here we use the Elasticsearch version and build hash, if the version is semantic, or just the hash, if it is not
* semantic (e.g. in serverless). The warn text must be quoted. The warn-date is an optional quoted field that can be in a variety of
* specified date formats; here we use RFC 1123 format.
* semantic (e.g. overridden with an arbitrary string by a org.elasticsearch.internal.BuildExtension implementation).
* The warn text must be quoted. The warn-date is an optional quoted field that can be in a variety of specified date formats; here we
* use RFC 1123 format.
*/
private static final String WARNING_PREFIX = buildWarningPrefix();

Expand Down Expand Up @@ -205,6 +206,7 @@ public static void removeThreadContext(ThreadContext threadContext) {
* {@code 299 Elasticsearch-6.0.0 "warning value"}, the return value of this method would be {@code warning value}.
*
* @param s the value of a warning header formatted according to RFC 7234.
* @param stripXContentPosition whether to remove XContent location information or not
* @return the extracted warning value
*/
public static String extractWarningValueFromWarningHeader(final String s, boolean stripXContentPosition) {
Expand Down

0 comments on commit 1e98245

Please sign in to comment.