Skip to content

Commit 7d3789c

Browse files
committed
Merge branch 'upstream/master' into tsdb-required-range-settings
* upstream/master: (55 commits) Fix ComposableIndexTemplate equals when composed_of is null (elastic#80864) Optimize DLS bitset building for matchAll query (elastic#81030) URL option for BaseRunAsSuperuserCommand (elastic#81025) Less Verbose Serialization of Snapshot Failure in SLM Metadata (elastic#80942) Fix shadowed vars pt7 (elastic#80996) Fail shards early when we can detect a type missmatch (elastic#79869) Delegate Ref Counting to ByteBuf in Netty Transport (elastic#81096) Clarify `unassigned.reason` docs (elastic#81017) Strip blocks from settings for reindex targets (elastic#80887) Split off the values supplier for ScriptDocValues (elastic#80635) [ML] Switch message and detail for model snapshot deprecations (elastic#81108) [DOCS] Update xrefs for snapshot restore docs (elastic#81023) [ML] Updates visiblity of validate API (elastic#81061) Track histogram of transport handling times (elastic#80581) [ML] Fix datafeed preview with remote indices (elastic#81099) [ML] Fix acceptable model snapshot versions in ML deprecation checker (elastic#81060) [ML] Add logging for failing PyTorch test (elastic#81044) Extending the timeout waiting for snapshot to be ready (elastic#81018) [ML] Fix incorrect logging of unexpected model size error (elastic#81089) [ML] Make inference timeout test more reliable (elastic#81094) ...
2 parents d025a4e + 2629c32 commit 7d3789c

File tree

344 files changed

+4867
-1893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+4867
-1893
lines changed

build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,15 @@ public class HiddenFieldCheck extends AbstractCheck {
7171
/** Control whether to ignore constructor parameters. */
7272
private boolean ignoreConstructorParameter;
7373

74+
/** Control whether to ignore variables in constructor bodies. */
75+
private boolean ignoreConstructorBody;
76+
7477
/** Control whether to ignore parameters of abstract methods. */
7578
private boolean ignoreAbstractMethods;
7679

80+
/** If set, specifies a regex of method names that should be ignored */
81+
private String ignoredMethodNames;
82+
7783
@Override
7884
public int[] getDefaultTokens() {
7985
return getAcceptableTokens();
@@ -224,7 +230,8 @@ private void processVariable(DetailAST ast) {
224230

225231
if ((frame.containsStaticField(name) || isInstanceField(ast, name))
226232
&& isMatchingRegexp(name) == false
227-
&& isIgnoredParam(ast, name) == false) {
233+
&& isIgnoredParam(ast, name) == false
234+
&& isIgnoredVariable(ast, name) == false) {
228235
log(nameAST, MSG_KEY, name);
229236
}
230237
}
@@ -238,7 +245,14 @@ && isIgnoredParam(ast, name) == false) {
238245
* @return true if parameter is ignored.
239246
*/
240247
private boolean isIgnoredParam(DetailAST ast, String name) {
241-
return isIgnoredSetterParam(ast, name) || isIgnoredConstructorParam(ast) || isIgnoredParamOfAbstractMethod(ast);
248+
return isVariableInIgnoredMethod(ast, name)
249+
|| isIgnoredSetterParam(ast, name)
250+
|| isIgnoredConstructorParam(ast)
251+
|| isIgnoredParamOfAbstractMethod(ast);
252+
}
253+
254+
private boolean isIgnoredVariable(DetailAST ast, String name) {
255+
return isIgnoredVariableInConstructorBody(ast, name);
242256
}
243257

244258
/**
@@ -410,6 +424,42 @@ private boolean isIgnoredParamOfAbstractMethod(DetailAST ast) {
410424
return result;
411425
}
412426

427+
/**
428+
* Decides whether to ignore an AST node that is the parameter of a method whose
429+
* name matches the {@link #ignoredMethodNames} regex, if set.
430+
* @param ast the AST to check
431+
* @return true is the ast should be ignored because the parameter belongs to a
432+
* method whose name matches the regex.
433+
*/
434+
private boolean isVariableInIgnoredMethod(DetailAST ast, String name) {
435+
boolean result = false;
436+
if (ignoredMethodNames != null && (ast.getType() == TokenTypes.PARAMETER_DEF || ast.getType() == TokenTypes.VARIABLE_DEF)) {
437+
DetailAST method = ast.getParent();
438+
while (method != null && method.getType() != TokenTypes.METHOD_DEF) {
439+
method = method.getParent();
440+
}
441+
if (method != null && method.getType() == TokenTypes.METHOD_DEF) {
442+
final String methodName = method.findFirstToken(TokenTypes.IDENT).getText();
443+
result = methodName.matches(ignoredMethodNames);
444+
}
445+
}
446+
return result;
447+
}
448+
449+
private boolean isIgnoredVariableInConstructorBody(DetailAST ast, String name) {
450+
boolean result = false;
451+
452+
if (ignoreConstructorBody && ast.getType() == TokenTypes.VARIABLE_DEF) {
453+
DetailAST method = ast.getParent();
454+
while (method != null && method.getType() != TokenTypes.CTOR_DEF) {
455+
method = method.getParent();
456+
}
457+
result = method != null && method.getType() == TokenTypes.CTOR_DEF;
458+
}
459+
460+
return result;
461+
}
462+
413463
/**
414464
* Setter to define the RegExp for names of variables and parameters to ignore.
415465
*
@@ -463,6 +513,14 @@ public void setIgnoreAbstractMethods(boolean ignoreAbstractMethods) {
463513
this.ignoreAbstractMethods = ignoreAbstractMethods;
464514
}
465515

516+
public void setIgnoredMethodNames(String ignoredMethodNames) {
517+
this.ignoredMethodNames = ignoredMethodNames;
518+
}
519+
520+
public void setIgnoreConstructorBody(boolean ignoreConstructorBody) {
521+
this.ignoreConstructorBody = ignoreConstructorBody;
522+
}
523+
466524
/**
467525
* Holds the names of static and instance fields of a type.
468526
*/

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public void execute(Task t) {
9797
"-Xmx" + System.getProperty("tests.heap.size", "512m"),
9898
"-Xms" + System.getProperty("tests.heap.size", "512m"),
9999
"--illegal-access=deny",
100+
"-Djava.security.manager=allow",
100101
// TODO: only open these for mockito when it is modularized
101102
"--add-opens=java.base/java.security.cert=ALL-UNNAMED",
102103
"--add-opens=java.base/java.nio.channels=ALL-UNNAMED",

build-tools-internal/src/main/resources/checkstyle.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@
111111
<!--
112112
<module name="org.elasticsearch.gradle.internal.checkstyle.HiddenFieldCheck">
113113
<property name="ignoreConstructorParameter" value="true" />
114+
<property name="ignoreConstructorBody" value="true"/>
114115
<property name="ignoreSetter" value="true" />
115116
<property name="setterCanReturnItsClass" value="true"/>
116-
<property name="ignoreFormat" value="^(threadPool)$"/>
117+
<property name="ignoreFormat" value="^(?:threadPool)$"/>
117118
<property name="ignoreAbstractMethods" value="true"/>
119+
<property name="ignoredMethodNames" value="^(?:createParser)$"/>
118120
<message key="hidden.field" value="''{0}'' hides a field." />
119121
</module>
120122
-->

build-tools/src/main/java/org/elasticsearch/gradle/Version.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public enum Mode {
3939

4040
private static final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(?:-(alpha\\d+|beta\\d+|rc\\d+|SNAPSHOT))?");
4141

42-
private static final Pattern relaxedPattern = Pattern.compile("v?(\\d+)\\.(\\d+)\\.(\\d+)(?:-([a-zA-Z0-9_]+(?:-[a-zA-Z0-9]+)*))?");
42+
private static final Pattern relaxedPattern = Pattern.compile(
43+
"v?(\\d+)\\.(\\d+)\\.(\\d+)(?:[\\-+]+([a-zA-Z0-9_]+(?:-[a-zA-Z0-9]+)*))?"
44+
);
4345

4446
public Version(int major, int minor, int revision) {
4547
this(major, minor, revision, null);

build-tools/src/test/java/org/elasticsearch/gradle/VersionTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void testRelaxedVersionParsing() {
4141
assertVersionEquals("6.1.2-foo", 6, 1, 2, Version.Mode.RELAXED);
4242
assertVersionEquals("6.1.2-foo-bar", 6, 1, 2, Version.Mode.RELAXED);
4343
assertVersionEquals("16.01.22", 16, 1, 22, Version.Mode.RELAXED);
44+
assertVersionEquals("20.10.10+dfsg1", 20, 10, 10, Version.Mode.RELAXED);
4445
}
4546

4647
public void testCompareWithStringVersions() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ static Request cancelTasks(CancelTasksRequest req) {
3434
}
3535

3636
static Request listTasks(ListTasksRequest listTaskRequest) {
37-
if (listTaskRequest.getTaskId() != null && listTaskRequest.getTaskId().isSet()) {
38-
throw new IllegalArgumentException("TaskId cannot be used for list tasks request");
37+
if (listTaskRequest.getTargetTaskId() != null && listTaskRequest.getTargetTaskId().isSet()) {
38+
throw new IllegalArgumentException("TargetTaskId cannot be used for list tasks request");
3939
}
4040
Request request = new Request(HttpGet.METHOD_NAME, "/_tasks");
4141
RequestConverters.Params params = new RequestConverters.Params();
4242
params.withTimeout(listTaskRequest.getTimeout())
4343
.withDetailed(listTaskRequest.getDetailed())
4444
.withWaitForCompletion(listTaskRequest.getWaitForCompletion())
45-
.withParentTaskId(listTaskRequest.getParentTaskId())
45+
.withParentTaskId(listTaskRequest.getTargetParentTaskId())
4646
.withNodes(listTaskRequest.getNodes())
4747
.withActions(listTaskRequest.getActions())
4848
.putParam("group_by", "none");

client/rest-high-level/src/test/java/org/elasticsearch/client/TasksRequestConvertersTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testListTasks() {
7272
if (randomBoolean()) {
7373
if (randomBoolean()) {
7474
TaskId taskId = new TaskId(randomAlphaOfLength(5), randomNonNegativeLong());
75-
request.setParentTaskId(taskId);
75+
request.setTargetParentTaskId(taskId);
7676
expectedParams.put("parent_task_id", taskId.toString());
7777
} else {
7878
request.setParentTask(TaskId.EMPTY_TASK_ID);
@@ -102,12 +102,12 @@ public void testListTasks() {
102102
}
103103
{
104104
ListTasksRequest request = new ListTasksRequest();
105-
request.setTaskId(new TaskId(randomAlphaOfLength(5), randomNonNegativeLong()));
105+
request.setTargetTaskId(new TaskId(randomAlphaOfLength(5), randomNonNegativeLong()));
106106
IllegalArgumentException exception = expectThrows(
107107
IllegalArgumentException.class,
108108
() -> TasksRequestConverters.listTasks(request)
109109
);
110-
assertEquals("TaskId cannot be used for list tasks request", exception.getMessage());
110+
assertEquals("TargetTaskId cannot be used for list tasks request", exception.getMessage());
111111
}
112112
}
113113
}

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testListTasks() throws IOException {
6767
// tag::list-tasks-request-filter
6868
request.setActions("cluster:*"); // <1>
6969
request.setNodes("nodeId1", "nodeId2"); // <2>
70-
request.setParentTaskId(new TaskId("parentTaskId", 42)); // <3>
70+
request.setTargetParentTaskId(new TaskId("parentTaskId", 42)); // <3>
7171
// end::list-tasks-request-filter
7272

7373
// tag::list-tasks-request-detailed

distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/BaseKeyStoreCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import joptsimple.OptionSpec;
1313

1414
import org.elasticsearch.cli.ExitCodes;
15-
import org.elasticsearch.cli.KeyStoreAwareCommand;
1615
import org.elasticsearch.cli.Terminal;
1716
import org.elasticsearch.cli.UserException;
17+
import org.elasticsearch.common.cli.KeyStoreAwareCommand;
1818
import org.elasticsearch.common.settings.KeyStoreWrapper;
1919
import org.elasticsearch.common.settings.SecureString;
2020
import org.elasticsearch.env.Environment;

distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/CreateKeyStoreCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import joptsimple.OptionSpec;
1313

1414
import org.elasticsearch.cli.ExitCodes;
15-
import org.elasticsearch.cli.KeyStoreAwareCommand;
1615
import org.elasticsearch.cli.Terminal;
1716
import org.elasticsearch.cli.UserException;
17+
import org.elasticsearch.common.cli.KeyStoreAwareCommand;
1818
import org.elasticsearch.common.settings.KeyStoreWrapper;
1919
import org.elasticsearch.common.settings.SecureString;
2020
import org.elasticsearch.env.Environment;

0 commit comments

Comments
 (0)