Skip to content

Commit ed014e5

Browse files
committed
Merge remote-tracking branch 'es/master' into ccr
* es/master: Added more parameter to PersistentTaskPlugin#getPersistentTasksExecutor(...) [Tests] Relax assertion in SuggestStatsIT (#28544) Make internal Rounding fields final (#28532) Fix the ability to remove old plugin [TEST] Expand failure message for wildfly integration tests Add 6.2.1 version constant Remove feature parsing for GetIndicesAction (#28535) No refresh on shard activation needed (#28013) Improve failure message when restoring an index that already exists in the cluster (#28498) Use right skip versions. [Docs] Fix incomplete URLs (#28528) Use non deprecated xcontenthelper (#28503) Painless: Fixes a null pointer exception in certain cases of for loop usage (#28506)
2 parents f50a4ca + 2023c98 commit ed014e5

File tree

37 files changed

+209
-147
lines changed

37 files changed

+209
-147
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.elasticsearch.common.bytes.BytesReference;
5959
import org.elasticsearch.common.lucene.uid.Versions;
6060
import org.elasticsearch.common.unit.TimeValue;
61+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
6162
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
6263
import org.elasticsearch.common.xcontent.ToXContent;
6364
import org.elasticsearch.common.xcontent.XContent;
@@ -316,7 +317,8 @@ static Request bulk(BulkRequest bulkRequest) throws IOException {
316317
BytesReference indexSource = indexRequest.source();
317318
XContentType indexXContentType = indexRequest.getContentType();
318319

319-
try (XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, indexSource, indexXContentType)) {
320+
try (XContentParser parser = XContentHelper.createParser(NamedXContentRegistry.EMPTY,
321+
LoggingDeprecationHandler.INSTANCE, indexSource, indexXContentType)) {
320322
try (XContentBuilder builder = XContentBuilder.builder(bulkContentType.xContent())) {
321323
builder.copyCurrentStructure(parser);
322324
source = builder.bytes().toBytesRef();

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.elasticsearch.common.CheckedFunction;
5252
import org.elasticsearch.common.ParseField;
5353
import org.elasticsearch.common.xcontent.ContextParser;
54+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
5455
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
5556
import org.elasticsearch.common.xcontent.XContentParser;
5657
import org.elasticsearch.common.xcontent.XContentType;
@@ -637,7 +638,8 @@ protected final <Resp> Resp parseEntity(final HttpEntity entity,
637638
if (xContentType == null) {
638639
throw new IllegalStateException("Unsupported Content-Type: " + entity.getContentType().getValue());
639640
}
640-
try (XContentParser parser = xContentType.xContent().createParser(registry, entity.getContent())) {
641+
try (XContentParser parser = xContentType.xContent().createParser(registry,
642+
LoggingDeprecationHandler.INSTANCE, entity.getContent())) {
641643
return entityParser.apply(parser);
642644
}
643645
}

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/RemovePluginCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void execute(Terminal terminal, Environment env, String pluginName, boolean purg
8686

8787
// first make sure nothing extends this plugin
8888
List<String> usedBy = new ArrayList<>();
89-
Set<PluginsService.Bundle> bundles = PluginsService.getPluginBundles(env.pluginsFile());
89+
Set<PluginsService.Bundle> bundles = PluginsService.getPluginBundles(env.pluginsFile(), false);
9090
for (PluginsService.Bundle bundle : bundles) {
9191
for (String extendedPlugin : bundle.plugin.getExtendedPlugins()) {
9292
if (extendedPlugin.equals(pluginName)) {

distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/RemovePluginCommandTests.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.elasticsearch.env.Environment;
3030
import org.elasticsearch.env.TestEnvironment;
3131
import org.elasticsearch.test.ESTestCase;
32+
import org.elasticsearch.test.VersionUtils;
3233
import org.junit.Before;
3334

3435
import java.io.BufferedReader;
@@ -41,6 +42,7 @@
4142

4243
import static org.hamcrest.CoreMatchers.containsString;
4344
import static org.hamcrest.CoreMatchers.not;
45+
import static org.hamcrest.Matchers.equalTo;
4446
import static org.hamcrest.Matchers.hasToString;
4547

4648
@LuceneTestCase.SuppressFileSystems("*")
@@ -78,19 +80,27 @@ public void setUp() throws Exception {
7880
env = TestEnvironment.newEnvironment(settings);
7981
}
8082

81-
void createPlugin(String name) throws Exception {
83+
void createPlugin(String name) throws IOException {
8284
createPlugin(env.pluginsFile(), name);
8385
}
8486

85-
void createPlugin(Path path, String name) throws Exception {
87+
void createPlugin(String name, Version version) throws IOException {
88+
createPlugin(env.pluginsFile(), name, version);
89+
}
90+
91+
void createPlugin(Path path, String name) throws IOException {
92+
createPlugin(path, name, Version.CURRENT);
93+
}
94+
95+
void createPlugin(Path path, String name, Version version) throws IOException {
8696
PluginTestUtil.writePluginProperties(
87-
path.resolve(name),
88-
"description", "dummy",
89-
"name", name,
90-
"version", "1.0",
91-
"elasticsearch.version", Version.CURRENT.toString(),
92-
"java.version", System.getProperty("java.specification.version"),
93-
"classname", "SomeClass");
97+
path.resolve(name),
98+
"description", "dummy",
99+
"name", name,
100+
"version", "1.0",
101+
"elasticsearch.version", version.toString(),
102+
"java.version", System.getProperty("java.specification.version"),
103+
"classname", "SomeClass");
94104
}
95105

96106
void createMetaPlugin(String name, String... plugins) throws Exception {
@@ -137,6 +147,18 @@ public void testBasic() throws Exception {
137147
assertRemoveCleaned(env);
138148
}
139149

150+
public void testRemoveOldVersion() throws Exception {
151+
createPlugin(
152+
"fake",
153+
VersionUtils.randomVersionBetween(
154+
random(),
155+
Version.CURRENT.minimumIndexCompatibilityVersion(),
156+
VersionUtils.getPreviousVersion()));
157+
removePlugin("fake", home, randomBoolean());
158+
assertThat(Files.exists(env.pluginsFile().resolve("fake")), equalTo(false));
159+
assertRemoveCleaned(env);
160+
}
161+
140162
public void testBasicMeta() throws Exception {
141163
createMetaPlugin("meta", "fake1");
142164
createPlugin("other");

docs/plugins/authors.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
The Elasticsearch repository contains examples of:
77

8-
* a https://github.com/elastic/elasticsearch/tree/master/plugins/custom-settings[Java plugin]
8+
* a https://github.com/elastic/elasticsearch/tree/master/plugins/examples/custom-settings[Java plugin]
99
which contains a plugin with custom settings.
10-
* a https://github.com/elastic/elasticsearch/tree/master/plugins/rest-handler[Java plugin]
10+
* a https://github.com/elastic/elasticsearch/tree/master/plugins/examples/rest-handler[Java plugin]
1111
which contains a plugin that registers a Rest handler.
1212
* a https://github.com/elastic/elasticsearch/tree/master/plugins/examples/rescore[Java plugin]
1313
which contains a rescore plugin.

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ScriptProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.fasterxml.jackson.core.JsonFactory;
2323

24+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
2425
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
2526
import org.elasticsearch.common.xcontent.XContentBuilder;
2627
import org.elasticsearch.common.xcontent.XContentParser;
@@ -97,7 +98,8 @@ public Factory(ScriptService scriptService) {
9798
public ScriptProcessor create(Map<String, Processor.Factory> registry, String processorTag,
9899
Map<String, Object> config) throws Exception {
99100
XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(config);
100-
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, builder.bytes().streamInput());
101+
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
102+
LoggingDeprecationHandler.INSTANCE, builder.bytes().streamInput());
101103
Script script = Script.parse(parser);
102104

103105
Arrays.asList("id", "source", "inline", "lang", "params", "options").forEach(config::remove);

modules/lang-painless/src/main/java/org/elasticsearch/painless/node/SFor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void analyze(Locals locals) {
7676
locals = Locals.newLocalScope(locals);
7777

7878
if (initializer != null) {
79-
if (initializer instanceof AStatement) {
79+
if (initializer instanceof SDeclBlock) {
8080
initializer.analyze(locals);
8181
} else if (initializer instanceof AExpression) {
8282
AExpression initializer = (AExpression)this.initializer;
@@ -87,6 +87,9 @@ void analyze(Locals locals) {
8787
if (!initializer.statement) {
8888
throw createError(new IllegalArgumentException("Not a statement."));
8989
}
90+
91+
initializer.expected = initializer.actual;
92+
this.initializer = initializer.cast(locals);
9093
} else {
9194
throw createError(new IllegalStateException("Illegal tree structure."));
9295
}
@@ -119,6 +122,9 @@ void analyze(Locals locals) {
119122
if (!afterthought.statement) {
120123
throw createError(new IllegalArgumentException("Not a statement."));
121124
}
125+
126+
afterthought.expected = afterthought.actual;
127+
afterthought = afterthought.cast(locals);
122128
}
123129

124130
if (block != null) {
@@ -197,6 +203,7 @@ void write(MethodWriter writer, Globals globals) {
197203
if (afterthought != null) {
198204
writer.mark(begin);
199205
afterthought.write(writer, globals);
206+
writer.writePop(MethodWriter.getType(afterthought.expected).getSize());
200207
}
201208

202209
if (afterthought != null || !allEscape) {

modules/lang-painless/src/test/java/org/elasticsearch/painless/BasicStatementTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ public void testDoWhileStatement() {
108108
}
109109

110110
public void testForStatement() {
111+
assertEquals(6, exec("int x, y; for (x = 0; x < 4; ++x) {y += x;} return y;"));
111112
assertEquals("aaaaaa", exec("String c = \"a\"; for (int x = 0; x < 5; ++x) c += \"a\"; return c;"));
112113

114+
assertEquals(6, exec("double test() { return 0.0; }" +
115+
"int x, y; for (test(); x < 4; test()) {y += x; ++x;} return y;"));
116+
113117
Object value = exec(
114118
" int[][] b = new int[5][5]; \n" +
115119
" for (int x = 0; x < 5; ++x) { \n" +

modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.common.bytes.BytesArray;
3232
import org.elasticsearch.common.inject.Inject;
3333
import org.elasticsearch.common.settings.Settings;
34+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3435
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
3536
import org.elasticsearch.common.xcontent.XContentParser;
3637
import org.elasticsearch.common.xcontent.XContentType;
@@ -105,7 +106,8 @@ protected void doExecute(RankEvalRequest request, ActionListener<RankEvalRespons
105106
String templateId = ratedRequest.getTemplateId();
106107
TemplateScript.Factory templateScript = scriptsWithoutParams.get(templateId);
107108
String resolvedRequest = templateScript.newInstance(params).execute();
108-
try (XContentParser subParser = createParser(namedXContentRegistry, new BytesArray(resolvedRequest), XContentType.JSON)) {
109+
try (XContentParser subParser = createParser(namedXContentRegistry,
110+
LoggingDeprecationHandler.INSTANCE, new BytesArray(resolvedRequest), XContentType.JSON)) {
109111
ratedSearchSource = SearchSourceBuilder.fromXContent(subParser);
110112
} catch (IOException e) {
111113
// if we fail parsing, put the exception into the errors map and continue

modules/reindex/src/main/java/org/elasticsearch/index/reindex/remote/RemoteScrollableHitSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.elasticsearch.ElasticsearchStatusException;
3131
import org.elasticsearch.Version;
3232
import org.elasticsearch.action.bulk.BackoffPolicy;
33+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3334
import org.elasticsearch.index.reindex.ScrollableHitSource;
3435
import org.elasticsearch.action.search.SearchRequest;
3536
import org.elasticsearch.client.ResponseException;
@@ -196,7 +197,7 @@ public void onSuccess(org.elasticsearch.client.Response response) {
196197
}
197198
// EMPTY is safe here because we don't call namedObject
198199
try (XContentParser xContentParser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY,
199-
content)) {
200+
LoggingDeprecationHandler.INSTANCE, content)) {
200201
parsedResponse = parser.apply(xContentParser, xContentType);
201202
} catch (ParsingException e) {
202203
/* Because we're streaming the response we can't get a copy of it here. The best we can do is hint that it

0 commit comments

Comments
 (0)