From c1efe471fb7d91e0275882bf7339bc2ce04aff66 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Thu, 2 Dec 2021 09:57:29 +0000 Subject: [PATCH] Checkstyle shadows vars pt8 (#81147) Part of #19752. Fix more instances where local variable names were shadowing field names. Also: * Remove unused bits and pieces from `XPackClientPlugin`. * Expand the possible method names that are skipped when checking for shadowed vars, and allow shadowed vars in builder classes. --- .../internal/checkstyle/HiddenFieldCheck.java | 42 ++++++++++------- .../action/IndicesRequestIT.java | 46 +++++++++---------- .../topmetrics/InternalTopMetricsTests.java | 6 +-- .../org/elasticsearch/license/License.java | 18 ++++---- .../elasticsearch/license/LicenseService.java | 8 ++-- .../org/elasticsearch/license/Licensing.java | 2 +- .../license/StartBasicClusterTask.java | 6 +-- .../license/XPackLicenseState.java | 16 ++++--- .../protocol/xpack/frozen/FreezeRequest.java | 1 + .../xpack/watcher/PutWatchRequest.java | 1 + .../xpack/core/DataTiersFeatureSetUsage.java | 4 +- .../xpack/core/XPackClientPlugin.java | 10 ---- .../elasticsearch/xpack/core/XPackPlugin.java | 5 +- .../core/action/DeleteDataStreamAction.java | 4 +- .../xpack/core/async/StoredAsyncResponse.java | 4 +- .../xpack/core/async/StoredAsyncTask.java | 4 +- .../core/ccr/action/FollowStatsAction.java | 6 +-- .../core/indexing/AsyncTwoPhaseIndexer.java | 6 +-- .../xpack/core/ml/MlMetadata.java | 8 ++-- .../xpack/core/ml/action/CloseJobAction.java | 4 +- .../core/ml/action/GetJobsStatsAction.java | 2 +- .../ml/action/GetModelSnapshotsAction.java | 4 +- .../core/ml/action/GetRecordsAction.java | 4 +- .../ml/action/GetTrainedModelsAction.java | 4 +- .../InferTrainedModelDeploymentAction.java | 8 ++-- .../xpack/core/ml/action/PostDataAction.java | 1 + .../action/PutDataFrameAnalyticsAction.java | 23 ++++++---- .../core/ml/action/StartDatafeedAction.java | 4 +- .../xpack/core/ml/calendars/Calendar.java | 4 +- .../core/ml/datafeed/DatafeedConfig.java | 4 +- .../core/ml/datafeed/DatafeedTimingStats.java | 4 +- .../core/ml/datafeed/DatafeedUpdate.java | 12 ++--- .../evaluation/classification/AucRoc.java | 16 ++++--- .../evaluation/classification/Precision.java | 8 ++-- .../evaluation/classification/Recall.java | 8 ++-- .../evaluation/outlierdetection/AucRoc.java | 8 ++-- .../classification/ClassificationStats.java | 4 +- .../dataframe/stats/common/MemoryUsage.java | 4 +- .../OutlierDetectionStats.java | 4 +- .../stats/regression/RegressionStats.java | 4 +- .../core/ml/inference/TrainedModelConfig.java | 12 ++--- .../allocation/TrainedModelAllocation.java | 8 ++-- .../xpack/core/ml/job/config/Detector.java | 16 +++---- .../xpack/core/ml/job/config/Job.java | 6 +-- .../xpack/core/ml/job/config/JobUpdate.java | 4 +- .../process/autodetect/state/DataCounts.java | 14 +++--- .../core/ml/job/results/AnomalyRecord.java | 20 ++++---- .../xpack/core/ml/job/results/Bucket.java | 4 +- .../ml/job/results/ForecastRequestStats.java | 4 +- .../core/LocalStateCompositeXPackPlugin.java | 2 +- .../xpack/core/XPackPluginTests.java | 2 +- .../action/role/PutRoleRequestTests.java | 3 +- .../user/GetUserPrivilegesRequestTests.java | 3 +- .../user/GetUserPrivilegesResponseTests.java | 3 +- .../expressiondsl/ExpressionParserTests.java | 2 +- .../ConfigurableClusterPrivilegesTests.java | 3 +- .../ManageApplicationPrivilegesTests.java | 3 +- .../xpack/enrich/AbstractEnrichProcessor.java | 12 ++--- .../xpack/enrich/EnrichPlugin.java | 4 +- .../xpack/enrich/EnrichPolicyRunner.java | 30 ++++++------ .../eql/execution/assembler/Criterion.java | 13 ++++-- .../string/StringContainsFunctionPipe.java | 4 +- .../xpack/eql/plan/logical/Join.java | 4 +- .../xpack/eql/plan/physical/EsQueryExec.java | 4 +- .../xpack/eql/plan/physical/SequenceExec.java | 4 +- .../querydsl/container/QueryContainer.java | 4 +- .../sp/SamlServiceProviderIndexTests.java | 1 - .../mapper/ExpressionRoleMappingTests.java | 4 +- .../security/authz/RoleDescriptorTests.java | 3 +- .../WatcherMetadataSerializationTests.java | 6 +-- 70 files changed, 269 insertions(+), 264 deletions(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java index a27558f046698..0d605c89c3d0e 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java @@ -30,6 +30,7 @@ import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.HashSet; +import java.util.List; import java.util.Locale; import java.util.Objects; import java.util.Set; @@ -342,24 +343,33 @@ private boolean isSetterMethod(DetailAST aMethodAST, String aName) { boolean isSetterMethod = false; // ES also allows setters with the same name as a property, and builder-style settings that start with "with". - if (("set" + capitalize(aName)).equals(methodName) || ("with" + capitalize(aName)).equals(methodName) || aName.equals(methodName)) { + final List possibleSetterNames = List.of( + "set" + capitalize(aName, true), + "set" + capitalize(aName, false), + "with" + capitalize(aName, true), + "with" + capitalize(aName, false), + aName + ); + + if (possibleSetterNames.contains(methodName)) { // method name did match set${Name}(${anyType} ${aName}) // where ${Name} is capitalized version of ${aName} // therefore this method is potentially a setter final DetailAST typeAST = aMethodAST.findFirstToken(TokenTypes.TYPE); final String returnType = typeAST.getFirstChild().getText(); - if (typeAST.findFirstToken(TokenTypes.LITERAL_VOID) != null || setterCanReturnItsClass && frame.isEmbeddedIn(returnType)) { - // this method has signature - // - // void set${Name}(${anyType} ${name}) - // - // and therefore considered to be a setter - // - // or - // - // return type is not void, but it is the same as the class - // where method is declared and and mSetterCanReturnItsClass - // is set to true + + // The method is named `setFoo`, `withFoo`, or just `foo` and returns void + final boolean returnsVoid = typeAST.findFirstToken(TokenTypes.LITERAL_VOID) != null; + + // Or the method is named as above, and returns the class type or a builder type. + // It ought to be possible to see if we're in a `${returnType}.Builder`, but for some reason the parse + // tree has `returnType` as `.` when the current class is `Builder` so instead assume that a class called `Builder` is OK. + final boolean returnsSelf = setterCanReturnItsClass && frame.isEmbeddedIn(returnType); + + final boolean returnsBuilder = setterCanReturnItsClass + && (frame.isEmbeddedIn(returnType + "Builder") || (frame.isEmbeddedIn("Builder"))); + + if (returnsVoid || returnsSelf || returnsBuilder) { isSetterMethod = true; } } @@ -374,13 +384,13 @@ private boolean isSetterMethod(DetailAST aMethodAST, String aName) { * @param name a property name * @return capitalized property name */ - private static String capitalize(final String name) { + private static String capitalize(final String name, boolean javaBeanCompliant) { String setterName = name; // we should not capitalize the first character if the second // one is a capital one, since according to JavaBeans spec // setXYzz() is a setter for XYzz property, not for xYzz one. - // @pugnascotia: unless the first char is 'x'. - if (name.length() == 1 || (Character.isUpperCase(name.charAt(1)) == false || name.charAt(0) == 'x')) { + // @pugnascotia: this is unhelpful in the Elasticsearch codebase. We have e.g. xContent -> setXContent, or nNeighbors -> nNeighbors. + if (name.length() == 1 || (javaBeanCompliant == false || Character.isUpperCase(name.charAt(1)) == false)) { setterName = name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1); } return setterName; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java index 2454599e58585..88240d88eee3e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java @@ -278,31 +278,31 @@ public void testBulk() { String[] bulkShardActions = new String[] { BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" }; interceptTransportActions(bulkShardActions); - List indices = new ArrayList<>(); + List indicesOrAliases = new ArrayList<>(); BulkRequest bulkRequest = new BulkRequest(); int numIndexRequests = iterations(1, 10); for (int i = 0; i < numIndexRequests; i++) { String indexOrAlias = randomIndexOrAlias(); bulkRequest.add(new IndexRequest(indexOrAlias).id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")); - indices.add(indexOrAlias); + indicesOrAliases.add(indexOrAlias); } int numDeleteRequests = iterations(1, 10); for (int i = 0; i < numDeleteRequests; i++) { String indexOrAlias = randomIndexOrAlias(); bulkRequest.add(new DeleteRequest(indexOrAlias).id("id")); - indices.add(indexOrAlias); + indicesOrAliases.add(indexOrAlias); } int numUpdateRequests = iterations(1, 10); for (int i = 0; i < numUpdateRequests; i++) { String indexOrAlias = randomIndexOrAlias(); bulkRequest.add(new UpdateRequest(indexOrAlias, "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1")); - indices.add(indexOrAlias); + indicesOrAliases.add(indexOrAlias); } internalCluster().coordOnlyNodeClient().bulk(bulkRequest).actionGet(); clearInterceptedActions(); - assertIndicesSubset(indices, bulkShardActions); + assertIndicesSubset(indicesOrAliases, bulkShardActions); } public void testGet() { @@ -342,36 +342,36 @@ public void testMultiTermVector() { String multiTermVectorsShardAction = MultiTermVectorsAction.NAME + "[shard][s]"; interceptTransportActions(multiTermVectorsShardAction); - List indices = new ArrayList<>(); + List indicesOrAliases = new ArrayList<>(); MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest(); int numDocs = iterations(1, 30); for (int i = 0; i < numDocs; i++) { String indexOrAlias = randomIndexOrAlias(); multiTermVectorsRequest.add(indexOrAlias, Integer.toString(i)); - indices.add(indexOrAlias); + indicesOrAliases.add(indexOrAlias); } internalCluster().coordOnlyNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet(); clearInterceptedActions(); - assertIndicesSubset(indices, multiTermVectorsShardAction); + assertIndicesSubset(indicesOrAliases, multiTermVectorsShardAction); } public void testMultiGet() { String multiGetShardAction = MultiGetAction.NAME + "[shard][s]"; interceptTransportActions(multiGetShardAction); - List indices = new ArrayList<>(); + List indicesOrAliases = new ArrayList<>(); MultiGetRequest multiGetRequest = new MultiGetRequest(); int numDocs = iterations(1, 30); for (int i = 0; i < numDocs; i++) { String indexOrAlias = randomIndexOrAlias(); multiGetRequest.add(indexOrAlias, Integer.toString(i)); - indices.add(indexOrAlias); + indicesOrAliases.add(indexOrAlias); } internalCluster().coordOnlyNodeClient().multiGet(multiGetRequest).actionGet(); clearInterceptedActions(); - assertIndicesSubset(indices, multiGetShardAction); + assertIndicesSubset(indicesOrAliases, multiGetShardAction); } public void testFlush() { @@ -385,9 +385,9 @@ public void testFlush() { internalCluster().coordOnlyNodeClient().admin().indices().flush(flushRequest).actionGet(); clearInterceptedActions(); - String[] indices = TestIndexNameExpressionResolver.newInstance() + String[] concreteIndexNames = TestIndexNameExpressionResolver.newInstance() .concreteIndexNames(client().admin().cluster().prepareState().get().getState(), flushRequest); - assertIndicesSubset(Arrays.asList(indices), indexShardActions); + assertIndicesSubset(Arrays.asList(concreteIndexNames), indexShardActions); } public void testForceMerge() { @@ -412,9 +412,9 @@ public void testRefresh() { internalCluster().coordOnlyNodeClient().admin().indices().refresh(refreshRequest).actionGet(); clearInterceptedActions(); - String[] indices = TestIndexNameExpressionResolver.newInstance() + String[] concreteIndexNames = TestIndexNameExpressionResolver.newInstance() .concreteIndexNames(client().admin().cluster().prepareState().get().getState(), refreshRequest); - assertIndicesSubset(Arrays.asList(indices), indexShardActions); + assertIndicesSubset(Arrays.asList(concreteIndexNames), indexShardActions); } public void testClearCache() { @@ -670,21 +670,21 @@ private String randomIndexOrAlias() { private String[] randomIndicesOrAliases() { int count = randomIntBetween(1, indices.size() * 2); // every index has an alias - String[] indices = new String[count]; + String[] randomNames = new String[count]; for (int i = 0; i < count; i++) { - indices[i] = randomIndexOrAlias(); + randomNames[i] = randomIndexOrAlias(); } - return indices; + return randomNames; } private String[] randomUniqueIndicesOrAliases() { String[] uniqueIndices = randomUniqueIndices(); - String[] indices = new String[uniqueIndices.length]; + String[] randomNames = new String[uniqueIndices.length]; int i = 0; for (String index : uniqueIndices) { - indices[i++] = randomBoolean() ? index + "-alias" : index; + randomNames[i++] = randomBoolean() ? index + "-alias" : index; } - return indices; + return randomNames; } private String[] randomUniqueIndices() { @@ -771,8 +771,8 @@ synchronized List consumeRequests(String action) { return requests.remove(action); } - synchronized void interceptTransportActions(String... actions) { - Collections.addAll(this.actions, actions); + synchronized void interceptTransportActions(String... transportActions) { + Collections.addAll(this.actions, transportActions); } synchronized void clearInterceptedActions() { diff --git a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetricsTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetricsTests.java index 98bcd93173a88..66f5ef4ec60a4 100644 --- a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetricsTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetricsTests.java @@ -336,7 +336,7 @@ private InternalTopMetrics createTestInstance( @Override protected InternalTopMetrics mutateInstance(InternalTopMetrics instance) throws IOException { String name = instance.getName(); - SortOrder sortOrder = instance.getSortOrder(); + SortOrder instanceSortOrder = instance.getSortOrder(); List metricNames = instance.getMetricNames(); int size = instance.getSize(); List topMetrics = instance.getTopMetrics(); @@ -345,7 +345,7 @@ protected InternalTopMetrics mutateInstance(InternalTopMetrics instance) throws name = randomAlphaOfLength(6); break; case 1: - sortOrder = sortOrder == SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC; + instanceSortOrder = instanceSortOrder == SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC; Collections.reverse(topMetrics); break; case 2: @@ -371,7 +371,7 @@ protected InternalTopMetrics mutateInstance(InternalTopMetrics instance) throws default: throw new IllegalArgumentException("bad mutation"); } - return new InternalTopMetrics(name, sortOrder, metricNames, size, topMetrics, instance.getMetadata()); + return new InternalTopMetrics(name, instanceSortOrder, metricNames, size, topMetrics, instance.getMetadata()); } /** diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java index 6026512c712dc..01b00800a843e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java @@ -575,11 +575,11 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t builder.humanReadable(true); } } - final int version; + final int licenseVersion; if (params.param(LICENSE_VERSION_MODE) != null && restViewMode) { - version = Integer.parseInt(params.param(LICENSE_VERSION_MODE)); + licenseVersion = Integer.parseInt(params.param(LICENSE_VERSION_MODE)); } else { - version = this.version; + licenseVersion = this.version; } if (restViewMode) { builder.field(Fields.STATUS, status().label()); @@ -587,11 +587,11 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t builder.field(Fields.UID, uid); final String bwcType = hideEnterprise && LicenseType.isEnterprise(type) ? LicenseType.PLATINUM.getTypeName() : type; builder.field(Fields.TYPE, bwcType); - if (version == VERSION_START) { + if (licenseVersion == VERSION_START) { builder.field(Fields.SUBSCRIPTION_TYPE, subscriptionType); } builder.timeField(Fields.ISSUE_DATE_IN_MILLIS, Fields.ISSUE_DATE, issueDate); - if (version == VERSION_START) { + if (licenseVersion == VERSION_START) { builder.field(Fields.FEATURE, feature); } @@ -599,7 +599,7 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t builder.timeField(Fields.EXPIRY_DATE_IN_MILLIS, Fields.EXPIRY_DATE, expiryDate); } - if (version >= VERSION_ENTERPRISE) { + if (licenseVersion >= VERSION_ENTERPRISE) { builder.field(Fields.MAX_NODES, maxNodes == -1 ? null : maxNodes); builder.field(Fields.MAX_RESOURCE_UNITS, maxResourceUnits == -1 ? null : maxResourceUnits); } else if (hideEnterprise && maxNodes == -1) { @@ -616,7 +616,7 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t if (restViewMode) { builder.humanReadable(previouslyHumanReadable); } - if (version >= VERSION_START_DATE) { + if (licenseVersion >= VERSION_START_DATE) { builder.timeField(Fields.START_DATE_IN_MILLIS, Fields.START_DATE, startDate); } return builder; @@ -939,7 +939,7 @@ public Builder startDate(long startDate) { return this; } - public Builder fromLicenseSpec(License license, String signature) { + public Builder fromLicenseSpec(License license, String licenseSignature) { return uid(license.uid()).version(license.version()) .issuedTo(license.issuedTo()) .issueDate(license.issueDate()) @@ -951,7 +951,7 @@ public Builder fromLicenseSpec(License license, String signature) { .maxResourceUnits(license.maxResourceUnits()) .expiryDate(license.expiryDate()) .issuer(license.issuer()) - .signature(signature); + .signature(licenseSignature); } /** diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index d294370979f2d..3cd169df87676 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -109,7 +109,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste /** * Currently active license */ - private final AtomicReference currentLicense = new AtomicReference<>(); + private final AtomicReference currentLicenseHolder = new AtomicReference<>(); private final SchedulerEngine scheduler; private final Clock clock; @@ -438,7 +438,7 @@ protected void doStop() throws ElasticsearchException { clusterService.removeListener(this); scheduler.stop(); // clear current license - currentLicense.set(null); + currentLicenseHolder.set(null); } @Override @@ -558,9 +558,9 @@ private void onUpdate(final LicensesMetadata currentLicensesMetadata) { // license can be null if the trial license is yet to be auto-generated // in this case, it is a no-op if (license != null) { - final License previousLicense = currentLicense.get(); + final License previousLicense = currentLicenseHolder.get(); if (license.equals(previousLicense) == false) { - currentLicense.set(license); + currentLicenseHolder.set(license); license.setOperationModeFileWatcher(operationModeFileWatcher); scheduler.add(new SchedulerEngine.Job(LICENSE_JOB, nextLicenseCheck(license))); for (ExpirationCallback expirationCallback : expirationCallbacks) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java index 2a3acd6bf022c..2ce9b55f50a19 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java @@ -75,7 +75,7 @@ public Licensing(Settings settings) { @Override public List getRestHandlers( - Settings settings, + Settings unused, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/StartBasicClusterTask.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/StartBasicClusterTask.java index cac19a6560e45..3fcfe4cea0962 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/StartBasicClusterTask.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/StartBasicClusterTask.java @@ -73,9 +73,9 @@ public ClusterState execute(ClusterState currentState) throws Exception { if (shouldGenerateNewBasicLicense(currentLicense)) { License selfGeneratedLicense = generateBasicLicense(currentState); if (request.isAcknowledged() == false && currentLicense != null) { - Map ackMessages = LicenseService.getAckMessages(selfGeneratedLicense, currentLicense); - if (ackMessages.isEmpty() == false) { - this.ackMessages.set(ackMessages); + Map ackMessageMap = LicenseService.getAckMessages(selfGeneratedLicense, currentLicense); + if (ackMessageMap.isEmpty() == false) { + this.ackMessages.set(ackMessageMap); return currentState; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index f95772eb7a4ce..0e050298a7ff9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -376,17 +376,19 @@ public void removeListener(final LicenseStateListener listener) { /** Return the current license type. */ public OperationMode getOperationMode() { - return executeAgainstStatus(status -> status.mode); + return executeAgainstStatus(statusToCheck -> statusToCheck.mode); } // Package private for tests /** Return true if the license is currently within its time boundaries, false otherwise. */ public boolean isActive() { - return checkAgainstStatus(status -> status.active); + return checkAgainstStatus(statusToCheck -> statusToCheck.active); } public String statusDescription() { - return executeAgainstStatus(status -> (status.active ? "active" : "expired") + ' ' + status.mode.description() + " license"); + return executeAgainstStatus( + statusToCheck -> (statusToCheck.active ? "active" : "expired") + ' ' + statusToCheck.mode.description() + " license" + ); } void featureUsed(LicensedFeature feature) { @@ -458,7 +460,7 @@ static boolean isAllowedByOperationMode(final OperationMode operationMode, final * is needed for multiple interactions with the license state. */ public XPackLicenseState copyCurrentLicenseState() { - return executeAgainstStatus(status -> new XPackLicenseState(listeners, status, usage, epochMillisProvider)); + return executeAgainstStatus(statusToCheck -> new XPackLicenseState(listeners, statusToCheck, usage, epochMillisProvider)); } /** @@ -471,11 +473,11 @@ public XPackLicenseState copyCurrentLicenseState() { */ @Deprecated public boolean isAllowedByLicense(OperationMode minimumMode, boolean needActive) { - return checkAgainstStatus(status -> { - if (needActive && false == status.active) { + return checkAgainstStatus(statusToCheck -> { + if (needActive && false == statusToCheck.active) { return false; } - return isAllowedByOperationMode(status.mode, minimumMode); + return isAllowedByOperationMode(statusToCheck.mode, minimumMode); }); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/frozen/FreezeRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/frozen/FreezeRequest.java index ea83e340841b1..f32fd515e7817 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/frozen/FreezeRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/frozen/FreezeRequest.java @@ -97,6 +97,7 @@ public FreezeRequest indicesOptions(IndicesOptions indicesOptions) { } @Override + @SuppressWarnings("HiddenField") public IndicesRequest indices(String... indices) { this.indices = indices; return this; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java index 9e863511d6ed1..63840a9de2223 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java @@ -97,6 +97,7 @@ public BytesReference getSource() { /** * Set the source of the watch */ + @SuppressWarnings("HiddenField") public void setSource(BytesReference source, XContentType xContentType) { this.source = source; this.xContentType = xContentType; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersFeatureSetUsage.java index d4bfd43aec44f..b82bebcdbc294 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersFeatureSetUsage.java @@ -58,8 +58,8 @@ public void writeTo(StreamOutput out) throws IOException { @Override protected void innerXContent(XContentBuilder builder, Params params) throws IOException { super.innerXContent(builder, params); - for (Map.Entry tierStats : tierStats.entrySet()) { - builder.field(tierStats.getKey(), tierStats.getValue()); + for (Map.Entry entry : tierStats.entrySet()) { + builder.field(entry.getKey(), entry.getValue()); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java index 3c4c240deecea..2e32a9990c5db 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.DeleteLicenseAction; import org.elasticsearch.license.GetBasicStatusAction; import org.elasticsearch.license.GetLicenseAction; @@ -232,19 +231,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Optional; // TODO: merge this into XPackPlugin public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPlugin { - static Optional X_PACK_FEATURE = Optional.of("x-pack"); - - private final Settings settings; - - public XPackClientPlugin(final Settings settings) { - this.settings = settings; - } - @Override public List> getSettings() { ArrayList> settings = new ArrayList<>(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java index 30968a2a33692..e03987482900d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java @@ -106,6 +106,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +@SuppressWarnings("HiddenField") public class XPackPlugin extends XPackClientPlugin implements ExtensiblePlugin, @@ -158,8 +159,8 @@ public Void run() { private static final SetOnce licenseService = new SetOnce<>(); private static final SetOnce epochMillisSupplier = new SetOnce<>(); - public XPackPlugin(final Settings settings, final Path configPath) { - super(settings); + public XPackPlugin(final Settings settings) { + super(); // FIXME: The settings might be changed after this (e.g. from "additionalSettings" method in other plugins) // We should only depend on the settings from the Environment object passed to createComponents this.settings = settings; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/DeleteDataStreamAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/DeleteDataStreamAction.java index b0c2345925743..e4ecc9b62bdc7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/DeleteDataStreamAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/DeleteDataStreamAction.java @@ -105,8 +105,8 @@ public IndicesOptions indicesOptions() { return indicesOptions; } - public IndicesRequest indicesOptions(IndicesOptions indicesOptions) { - this.indicesOptions = indicesOptions; + public IndicesRequest indicesOptions(IndicesOptions options) { + this.indicesOptions = options; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncResponse.java index cff42f5800543..57256d8355d63 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncResponse.java @@ -54,8 +54,8 @@ public long getExpirationTime() { } @Override - public StoredAsyncResponse withExpirationTime(long expirationTimeMillis) { - return new StoredAsyncResponse<>(this.response, this.exception, expirationTimeMillis); + public StoredAsyncResponse withExpirationTime(long expirationTime) { + return new StoredAsyncResponse<>(this.response, this.exception, expirationTime); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncTask.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncTask.java index 1a61f48b2d982..8e2f9a209a13e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncTask.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/StoredAsyncTask.java @@ -57,8 +57,8 @@ public AsyncExecutionId getExecutionId() { * Update the expiration time of the (partial) response. */ @Override - public void setExpirationTime(long expirationTimeMillis) { - this.expirationTimeMillis = expirationTimeMillis; + public void setExpirationTime(long expirationTime) { + this.expirationTimeMillis = expirationTime; } public long getExpirationTimeMillis() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java index 977d269db588a..1b0a67ee1a782 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java @@ -72,9 +72,9 @@ public void writeTo(StreamOutput out) throws IOException { public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { // sort by index name, then shard ID final Map> taskResponsesByIndex = new TreeMap<>(); - for (final StatsResponse statsResponse : statsResponse) { - taskResponsesByIndex.computeIfAbsent(statsResponse.status().followerIndex(), k -> new TreeMap<>()) - .put(statsResponse.status().getShardId(), statsResponse); + for (final StatsResponse response : statsResponse) { + taskResponsesByIndex.computeIfAbsent(response.status().followerIndex(), k -> new TreeMap<>()) + .put(response.status().getShardId(), response); } builder.startObject(); { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/AsyncTwoPhaseIndexer.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/AsyncTwoPhaseIndexer.java index 03afa3e477358..ef0a1ac27182a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/AsyncTwoPhaseIndexer.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexing/AsyncTwoPhaseIndexer.java @@ -555,7 +555,7 @@ private void onSearchResponse(SearchResponse searchResponse) { position.set(newPosition); if (triggerSaveState()) { - doSaveState(IndexerState.INDEXING, newPosition, () -> { nextSearch(); }); + doSaveState(IndexerState.INDEXING, newPosition, this::nextSearch); } else { nextSearch(); } @@ -568,7 +568,7 @@ private void onSearchResponse(SearchResponse searchResponse) { } } - private void onBulkResponse(BulkResponse response, JobPosition position) { + private void onBulkResponse(BulkResponse response, JobPosition jobPosition) { stats.markEndIndexing(); // check if we should stop @@ -578,7 +578,7 @@ private void onBulkResponse(BulkResponse response, JobPosition position) { try { if (triggerSaveState()) { - doSaveState(IndexerState.INDEXING, position, () -> { nextSearch(); }); + doSaveState(IndexerState.INDEXING, jobPosition, this::nextSearch); } else { nextSearch(); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetadata.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetadata.java index 3b79b0ec66f8a..7c0bc35ab09cf 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetadata.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetadata.java @@ -220,13 +220,13 @@ public Builder(@Nullable MlMetadata previous) { } } - public Builder isUpgradeMode(boolean upgradeMode) { - this.upgradeMode = upgradeMode; + public Builder isUpgradeMode(boolean isUpgradeMode) { + this.upgradeMode = isUpgradeMode; return this; } - public Builder isResetMode(boolean resetMode) { - this.resetMode = resetMode; + public Builder isResetMode(boolean isResetMode) { + this.resetMode = isResetMode; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/CloseJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/CloseJobAction.java index b45c1168b86ca..fbaa2b8b65141 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/CloseJobAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/CloseJobAction.java @@ -121,8 +121,8 @@ public TimeValue getCloseTimeout() { return timeout; } - public Request setCloseTimeout(TimeValue timeout) { - this.timeout = timeout; + public Request setCloseTimeout(TimeValue closeTimeout) { + this.timeout = closeTimeout; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java index 78036761bc459..0a83672c141af 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetJobsStatsAction.java @@ -108,7 +108,7 @@ public boolean allowNoMatch() { @Override public boolean match(Task task) { - return expandedJobsIds.stream().anyMatch(jobId -> OpenJobAction.JobTaskMatcher.match(task, jobId)); + return expandedJobsIds.stream().anyMatch(id -> OpenJobAction.JobTaskMatcher.match(task, id)); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetModelSnapshotsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetModelSnapshotsAction.java index 6135eae0e23f6..8ef588ffa08d0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetModelSnapshotsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetModelSnapshotsAction.java @@ -115,8 +115,8 @@ public boolean getDescOrder() { return desc; } - public void setDescOrder(boolean desc) { - this.desc = desc; + public void setDescOrder(boolean descOrder) { + this.desc = descOrder; } public PageParams getPageParams() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetRecordsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetRecordsAction.java index 05691448f33ee..6922d2f747182 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetRecordsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetRecordsAction.java @@ -140,8 +140,8 @@ public double getRecordScoreFilter() { return recordScoreFilter; } - public void setRecordScore(double recordScoreFilter) { - this.recordScoreFilter = recordScoreFilter; + public void setRecordScore(double recordScore) { + this.recordScoreFilter = recordScore; } public String getSort() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetTrainedModelsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetTrainedModelsAction.java index 52e426cfbcfe7..3b547a4708d3b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetTrainedModelsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetTrainedModelsAction.java @@ -213,8 +213,8 @@ public Builder setTotalCount(long totalCount) { return this; } - public Builder setModels(List configs) { - this.configs = configs; + public Builder setModels(List models) { + this.configs = models; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/InferTrainedModelDeploymentAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/InferTrainedModelDeploymentAction.java index 5b9619076f380..3599619a9c27c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/InferTrainedModelDeploymentAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/InferTrainedModelDeploymentAction.java @@ -195,8 +195,8 @@ public Builder setDocs(List> docs) { return this; } - public Builder setInferenceTimeout(TimeValue timeout) { - this.timeout = timeout; + public Builder setInferenceTimeout(TimeValue inferenceTimeout) { + this.timeout = inferenceTimeout; return this; } @@ -205,8 +205,8 @@ public Builder setUpdate(InferenceConfigUpdate update) { return this; } - private Builder setInferenceTimeout(String timeout) { - return setInferenceTimeout(TimeValue.parseTimeValue(timeout, TIMEOUT.getPreferredName())); + private Builder setInferenceTimeout(String inferenceTimeout) { + return setInferenceTimeout(TimeValue.parseTimeValue(inferenceTimeout, TIMEOUT.getPreferredName())); } public Request build() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostDataAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostDataAction.java index f149ded0a4725..f245b6a9754b4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostDataAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostDataAction.java @@ -167,6 +167,7 @@ public XContentType getXContentType() { return xContentType; } + @SuppressWarnings("HiddenField") public void setContent(BytesReference content, XContentType xContentType) { this.content = content; this.xContentType = xContentType; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PutDataFrameAnalyticsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PutDataFrameAnalyticsAction.java index a2004b839d8c8..dbc1f27b44ae3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PutDataFrameAnalyticsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PutDataFrameAnalyticsAction.java @@ -97,18 +97,23 @@ public ActionRequestValidationException validate() { } private ActionRequestValidationException checkConfigIdIsValid( - DataFrameAnalyticsConfig config, + DataFrameAnalyticsConfig analyticsConfig, ActionRequestValidationException error ) { - if (MlStrings.isValidId(config.getId()) == false) { + if (MlStrings.isValidId(analyticsConfig.getId()) == false) { error = ValidateActions.addValidationError( - Messages.getMessage(Messages.INVALID_ID, DataFrameAnalyticsConfig.ID, config.getId()), + Messages.getMessage(Messages.INVALID_ID, DataFrameAnalyticsConfig.ID, analyticsConfig.getId()), error ); } - if (MlStrings.hasValidLengthForId(config.getId()) == false) { + if (MlStrings.hasValidLengthForId(analyticsConfig.getId()) == false) { error = ValidateActions.addValidationError( - Messages.getMessage(Messages.ID_TOO_LONG, DataFrameAnalyticsConfig.ID, config.getId(), MlStrings.ID_LENGTH_LIMIT), + Messages.getMessage( + Messages.ID_TOO_LONG, + DataFrameAnalyticsConfig.ID, + analyticsConfig.getId(), + MlStrings.ID_LENGTH_LIMIT + ), error ); } @@ -116,14 +121,14 @@ private ActionRequestValidationException checkConfigIdIsValid( } private ActionRequestValidationException checkNoIncludedAnalyzedFieldsAreExcludedBySourceFiltering( - DataFrameAnalyticsConfig config, + DataFrameAnalyticsConfig analyticsConfig, ActionRequestValidationException error ) { - if (config.getAnalyzedFields() == null) { + if (analyticsConfig.getAnalyzedFields() == null) { return error; } - for (String analyzedInclude : config.getAnalyzedFields().includes()) { - if (config.getSource().isFieldExcluded(analyzedInclude)) { + for (String analyzedInclude : analyticsConfig.getAnalyzedFields().includes()) { + if (analyticsConfig.getSource().isFieldExcluded(analyzedInclude)) { return ValidateActions.addValidationError( "field [" + analyzedInclude diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java index 08c03c15008ab..4ac3e741e4f49 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java @@ -115,8 +115,8 @@ public void writeTo(StreamOutput out) throws IOException { } @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - this.params.toXContent(builder, params); + public XContentBuilder toXContent(XContentBuilder builder, Params xContentParams) throws IOException { + this.params.toXContent(builder, xContentParams); return builder; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java index 8f1970514bd9e..00d3f1ab59706 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java @@ -152,8 +152,8 @@ public String getId() { return calendarId; } - public void setId(String calendarId) { - this.calendarId = calendarId; + public void setId(String id) { + this.calendarId = id; } public Builder setJobIds(List jobIds) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java index d3ad5dd721dbd..cdcca062638f8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java @@ -957,11 +957,11 @@ public Builder setParsedAggregations(AggregatorFactories.Builder aggregations) { return this; } - private Builder setAggregationsSafe(AggProvider aggProvider) { + private Builder setAggregationsSafe(AggProvider provider) { if (this.aggProvider != null) { throw ExceptionsHelper.badRequestException("Found two aggregation definitions: [aggs] and [aggregations]"); } - this.aggProvider = aggProvider; + this.aggProvider = provider; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedTimingStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedTimingStats.java index c736ef1f7ae6d..d3ec7e78f46ab 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedTimingStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedTimingStats.java @@ -146,8 +146,8 @@ public void incrementSearchTimeMs(double searchTimeMs) { this.exponentialAvgCalculationContext.increment(searchTimeMs); } - public void incrementBucketCount(long bucketCount) { - this.bucketCount += bucketCount; + public void incrementBucketCount(long count) { + this.bucketCount += count; } public void setLatestRecordTimestamp(Instant latestRecordTimestamp) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java index 76951db37131e..2541a2c5c5cad 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java @@ -529,21 +529,21 @@ public Builder setFrequency(TimeValue frequency) { return this; } - public Builder setQuery(QueryProvider queryProvider) { - this.queryProvider = queryProvider; + public Builder setQuery(QueryProvider query) { + this.queryProvider = query; return this; } - private Builder setAggregationsSafe(AggProvider aggProvider) { + private Builder setAggregationsSafe(AggProvider provider) { if (this.aggProvider != null) { throw ExceptionsHelper.badRequestException("Found two aggregation definitions: [aggs] and [aggregations]"); } - setAggregations(aggProvider); + setAggregations(provider); return this; } - public Builder setAggregations(AggProvider aggProvider) { - this.aggProvider = aggProvider; + public Builder setAggregations(AggProvider provider) { + this.aggProvider = provider; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/AucRoc.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/AucRoc.java index affe6e06f4f9c..f7e80e7fcf972 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/AucRoc.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/AucRoc.java @@ -145,24 +145,26 @@ public int hashCode() { @Override public Tuple, List> aggs( EvaluationParameters parameters, - EvaluationFields fields + EvaluationFields evaluationFields ) { if (result.get() != null) { return Tuple.tuple(List.of(), List.of()); } // Store given {@code fields} for the purpose of generating error messages in {@code process}. - this.fields.trySet(fields); + this.fields.trySet(evaluationFields); double[] percentiles = IntStream.range(1, 100).mapToDouble(v -> (double) v).toArray(); AggregationBuilder percentilesAgg = AggregationBuilders.percentiles(PERCENTILES_AGG_NAME) - .field(fields.getPredictedProbabilityField()) + .field(evaluationFields.getPredictedProbabilityField()) .percentiles(percentiles); - AggregationBuilder nestedAgg = AggregationBuilders.nested(NESTED_AGG_NAME, fields.getTopClassesField()) + AggregationBuilder nestedAgg = AggregationBuilders.nested(NESTED_AGG_NAME, evaluationFields.getTopClassesField()) .subAggregation( - AggregationBuilders.filter(NESTED_FILTER_AGG_NAME, QueryBuilders.termQuery(fields.getPredictedClassField(), className)) - .subAggregation(percentilesAgg) + AggregationBuilders.filter( + NESTED_FILTER_AGG_NAME, + QueryBuilders.termQuery(evaluationFields.getPredictedClassField(), className) + ).subAggregation(percentilesAgg) ); - QueryBuilder actualIsTrueQuery = QueryBuilders.termQuery(fields.getActualField(), className); + QueryBuilder actualIsTrueQuery = QueryBuilders.termQuery(evaluationFields.getActualField(), className); AggregationBuilder percentilesForClassValueAgg = AggregationBuilders.filter(TRUE_AGG_NAME, actualIsTrueQuery) .subAggregation(nestedAgg); AggregationBuilder percentilesForRestAgg = AggregationBuilders.filter( diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java index b7b41844a3371..91f6d394deb83 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java @@ -101,15 +101,15 @@ public final Tuple, List> a EvaluationParameters parameters, EvaluationFields fields ) { - String actualField = fields.getActualField(); + String actualFieldName = fields.getActualField(); String predictedField = fields.getPredictedField(); // Store given {@code actualField} for the purpose of generating error message in {@code process}. - this.actualField.trySet(actualField); + this.actualField.trySet(actualFieldName); if (topActualClassNames.get() == null) { // This is step 1 return Tuple.tuple( List.of( AggregationBuilders.terms(ACTUAL_CLASSES_NAMES_AGG_NAME) - .field(actualField) + .field(actualFieldName) .order(List.of(BucketOrder.count(false), BucketOrder.key(true))) .size(MAX_CLASSES_CARDINALITY) ), @@ -121,7 +121,7 @@ public final Tuple, List> a .stream() .map(className -> new KeyedFilter(className, QueryBuilders.matchQuery(predictedField, className).lenient(true))) .toArray(KeyedFilter[]::new); - Script script = PainlessScripts.buildIsEqualScript(actualField, predictedField); + Script script = PainlessScripts.buildIsEqualScript(actualFieldName, predictedField); return Tuple.tuple( List.of( AggregationBuilders.filters(BY_PREDICTED_CLASS_AGG_NAME, keyedFiltersPredicted) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java index 1413ea1dadda1..42d016a84d452 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java @@ -95,18 +95,18 @@ public final Tuple, List> a EvaluationParameters parameters, EvaluationFields fields ) { - String actualField = fields.getActualField(); + String actualFieldName = fields.getActualField(); String predictedField = fields.getPredictedField(); // Store given {@code actualField} for the purpose of generating error message in {@code process}. - this.actualField.trySet(actualField); + this.actualField.trySet(actualFieldName); if (result.get() != null) { return Tuple.tuple(List.of(), List.of()); } - Script script = PainlessScripts.buildIsEqualScript(actualField, predictedField); + Script script = PainlessScripts.buildIsEqualScript(actualFieldName, predictedField); return Tuple.tuple( List.of( AggregationBuilders.terms(BY_ACTUAL_CLASS_AGG_NAME) - .field(actualField) + .field(actualFieldName) .order(List.of(BucketOrder.count(false), BucketOrder.key(true))) .size(MAX_CLASSES_CARDINALITY) .subAggregation(AggregationBuilders.avg(PER_ACTUAL_CLASS_RECALL_AGG_NAME).script(script)) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/AucRoc.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/AucRoc.java index d90657a2ab8a0..e15148b5fd7e1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/AucRoc.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/AucRoc.java @@ -131,16 +131,16 @@ public int hashCode() { @Override public Tuple, List> aggs( EvaluationParameters parameters, - EvaluationFields fields + EvaluationFields evaluationFields ) { if (result.get() != null) { return Tuple.tuple(List.of(), List.of()); } // Store given {@code fields} for the purpose of generating error messages in {@code process}. - this.fields.trySet(fields); + this.fields.trySet(evaluationFields); - String actualField = fields.getActualField(); - String predictedProbabilityField = fields.getPredictedProbabilityField(); + String actualField = evaluationFields.getActualField(); + String predictedProbabilityField = evaluationFields.getPredictedProbabilityField(); double[] percentiles = IntStream.range(1, 100).mapToDouble(v -> (double) v).toArray(); AggregationBuilder percentilesAgg = AggregationBuilders.percentiles(PERCENTILES_AGG_NAME) .field(predictedProbabilityField) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ClassificationStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ClassificationStats.java index 51f06b9c7f52a..8b7cff0e80441 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ClassificationStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ClassificationStats.java @@ -158,8 +158,8 @@ public int hashCode() { return Objects.hash(jobId, timestamp, iteration, hyperparameters, timingStats, validationLoss); } - public String documentId(String jobId) { - return documentIdPrefix(jobId) + timestamp.toEpochMilli(); + public String documentId(String _jobId) { + return documentIdPrefix(_jobId) + timestamp.toEpochMilli(); } public static String documentIdPrefix(String jobId) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/MemoryUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/MemoryUsage.java index 52890f9f3b5f8..9e9ff3e759e49 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/MemoryUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/MemoryUsage.java @@ -164,9 +164,9 @@ public String toString() { return Strings.toString(this); } - public String documentId(String jobId) { + public String documentId(String _jobId) { assert timestamp != null; - return documentIdPrefix(jobId) + timestamp.toEpochMilli(); + return documentIdPrefix(_jobId) + timestamp.toEpochMilli(); } public static String documentIdPrefix(String jobId) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/outlierdetection/OutlierDetectionStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/outlierdetection/OutlierDetectionStats.java index b7f6bb7118f68..6ddc078bef4af 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/outlierdetection/OutlierDetectionStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/outlierdetection/OutlierDetectionStats.java @@ -124,8 +124,8 @@ public int hashCode() { return Objects.hash(jobId, timestamp, parameters, timingStats); } - public String documentId(String jobId) { - return documentIdPrefix(jobId) + timestamp.toEpochMilli(); + public String documentId(String _jobId) { + return documentIdPrefix(_jobId) + timestamp.toEpochMilli(); } public static String documentIdPrefix(String jobId) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/RegressionStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/RegressionStats.java index 8b92ea64283aa..7fff20bcb68ee 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/RegressionStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/RegressionStats.java @@ -158,8 +158,8 @@ public int hashCode() { return Objects.hash(jobId, timestamp, iteration, hyperparameters, timingStats, validationLoss); } - public String documentId(String jobId) { - return documentIdPrefix(jobId) + timestamp.toEpochMilli(); + public String documentId(String _jobId) { + return documentIdPrefix(_jobId) + timestamp.toEpochMilli(); } public static String documentIdPrefix(String jobId) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java index b10d45124c7a6..ee2cf138b0583 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java @@ -647,19 +647,19 @@ private Builder addToMetadata(String fieldName, Object value) { return this; } - public Builder setParsedDefinition(TrainedModelDefinition.Builder definition) { - if (definition == null) { + public Builder setParsedDefinition(TrainedModelDefinition.Builder definitionRef) { + if (definitionRef == null) { return this; } - this.definition = LazyModelDefinition.fromParsedDefinition(definition.build()); + this.definition = LazyModelDefinition.fromParsedDefinition(definitionRef.build()); return this; } - public Builder setDefinitionFromBytes(BytesReference definition) { - if (definition == null) { + public Builder setDefinitionFromBytes(BytesReference definitionRef) { + if (definitionRef == null) { return this; } - this.definition = LazyModelDefinition.fromCompressedData(definition); + this.definition = LazyModelDefinition.fromCompressedData(definitionRef); return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/allocation/TrainedModelAllocation.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/allocation/TrainedModelAllocation.java index 5e26ce129a889..b90fe0af74b19 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/allocation/TrainedModelAllocation.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/allocation/TrainedModelAllocation.java @@ -268,7 +268,7 @@ Builder addRoutingEntry(String nodeId, RoutingState state) { return this; } - public Builder addNewFailedRoutingEntry(String nodeId, String reason) { + public Builder addNewFailedRoutingEntry(String nodeId, String failureReason) { if (nodeRoutingTable.containsKey(nodeId)) { throw new ResourceAlreadyExistsException( "routing entry for node [{}] for model [{}] already exists", @@ -277,7 +277,7 @@ public Builder addNewFailedRoutingEntry(String nodeId, String reason) { ); } isChanged = true; - nodeRoutingTable.put(nodeId, new RoutingStateAndReason(RoutingState.FAILED, reason)); + nodeRoutingTable.put(nodeId, new RoutingStateAndReason(RoutingState.FAILED, failureReason)); return this; } @@ -314,12 +314,12 @@ public Builder setReason(String reason) { return this; } - public Builder stopAllocation(String reason) { + public Builder stopAllocation(String stopReason) { if (allocationState.equals(AllocationState.STOPPING)) { return this; } isChanged = true; - this.reason = reason; + this.reason = stopReason; allocationState = AllocationState.STOPPING; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java index f8ebd02e98a55..77331ba9e0c6a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java @@ -594,9 +594,9 @@ public Detector build() { verifyFieldName(field); } - DetectorFunction function = this.function == null ? DetectorFunction.METRIC : this.function; + DetectorFunction detectorFunction = this.function == null ? DetectorFunction.METRIC : this.function; for (DetectionRule rule : rules) { - validateRule(rule, function); + validateRule(rule, detectorFunction); } // partition, by and over field names cannot be duplicates @@ -671,7 +671,7 @@ public Detector build() { return new Detector( detectorDescription, - function, + detectorFunction, fieldName, byFieldName, overFieldName, @@ -715,14 +715,14 @@ private static boolean containsInvalidChar(String field) { return field.chars().anyMatch(Character::isISOControl); } - private void validateRule(DetectionRule rule, DetectorFunction function) { - checkFunctionHasRuleSupport(rule, function); + private void validateRule(DetectionRule rule, DetectorFunction detectorFunction) { + checkFunctionHasRuleSupport(rule, detectorFunction); checkScoping(rule); } - private void checkFunctionHasRuleSupport(DetectionRule rule, DetectorFunction function) { - if (ruleHasConditionOnResultValue(rule) && FUNCTIONS_WITHOUT_RULE_CONDITION_SUPPORT.contains(function)) { - String msg = Messages.getMessage(Messages.JOB_CONFIG_DETECTION_RULE_NOT_SUPPORTED_BY_FUNCTION, function); + private void checkFunctionHasRuleSupport(DetectionRule rule, DetectorFunction detectorFunction) { + if (ruleHasConditionOnResultValue(rule) && FUNCTIONS_WITHOUT_RULE_CONDITION_SUPPORT.contains(detectorFunction)) { + String msg = Messages.getMessage(Messages.JOB_CONFIG_DETECTION_RULE_NOT_SUPPORTED_BY_FUNCTION, detectorFunction); throw ExceptionsHelper.badRequestException(msg); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java index 289c887c3b6a9..fd0ca90e13afd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java @@ -916,8 +916,8 @@ public Builder setFinishedTime(Date finishedTime) { return this; } - public Builder setDataDescription(DataDescription.Builder description) { - dataDescription = ExceptionsHelper.requireNonNull(description, DATA_DESCRIPTION.getPreferredName()).build(); + public Builder setDataDescription(DataDescription.Builder dataDescription) { + this.dataDescription = ExceptionsHelper.requireNonNull(dataDescription, DATA_DESCRIPTION.getPreferredName()).build(); return this; } @@ -1266,7 +1266,7 @@ public void validateDetectorsAreUnique() { * @param createTime The time this job was created * @return The job */ - public Job build(Date createTime) { + public Job build(@SuppressWarnings("HiddenField") Date createTime) { setCreateTime(createTime); setJobVersion(Version.CURRENT); return build(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java index 4ef013324d6d3..0ce7366d4a281 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java @@ -888,8 +888,8 @@ public Builder setAllowLazyOpen(boolean allowLazyOpen) { return this; } - public Builder setClearFinishTime(boolean clearJobFinishTime) { - this.clearJobFinishTime = clearJobFinishTime; + public Builder setClearFinishTime(boolean clearFinishTime) { + this.clearJobFinishTime = clearFinishTime; return this; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java index 60ef264417c9c..25f86c6cdc35a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java @@ -482,10 +482,9 @@ public void setLatestEmptyBucketTimeStamp(Date latestEmptyBucketTimeStamp) { this.latestEmptyBucketTimeStamp = latestEmptyBucketTimeStamp; } - public void updateLatestEmptyBucketTimeStamp(Date latestEmptyBucketTimeStamp) { - if (latestEmptyBucketTimeStamp != null - && (this.latestEmptyBucketTimeStamp == null || latestEmptyBucketTimeStamp.after(this.latestEmptyBucketTimeStamp))) { - this.latestEmptyBucketTimeStamp = latestEmptyBucketTimeStamp; + public void updateLatestEmptyBucketTimeStamp(Date timestamp) { + if (timestamp != null && (this.latestEmptyBucketTimeStamp == null || timestamp.after(this.latestEmptyBucketTimeStamp))) { + this.latestEmptyBucketTimeStamp = timestamp; } } @@ -502,10 +501,9 @@ public void setLatestSparseBucketTimeStamp(Date latestSparseBucketTimeStamp) { this.latestSparseBucketTimeStamp = latestSparseBucketTimeStamp; } - public void updateLatestSparseBucketTimeStamp(Date latestSparseBucketTimeStamp) { - if (latestSparseBucketTimeStamp != null - && (this.latestSparseBucketTimeStamp == null || latestSparseBucketTimeStamp.after(this.latestSparseBucketTimeStamp))) { - this.latestSparseBucketTimeStamp = latestSparseBucketTimeStamp; + public void updateLatestSparseBucketTimeStamp(Date timestamp) { + if (timestamp != null && (this.latestSparseBucketTimeStamp == null || timestamp.after(this.latestSparseBucketTimeStamp))) { + this.latestSparseBucketTimeStamp = timestamp; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java index c00941e5e178e..fb4ed695e00e8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java @@ -317,8 +317,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } Map> inputFields = inputFieldMap(); - for (String fieldName : inputFields.keySet()) { - builder.field(fieldName, inputFields.get(fieldName)); + for (String inputFieldName : inputFields.keySet()) { + builder.field(inputFieldName, inputFields.get(inputFieldName)); } builder.endObject(); return builder; @@ -334,19 +334,19 @@ private Map> inputFieldMap() { if (influences != null) { for (Influence inf : influences) { - String fieldName = inf.getInfluencerFieldName(); + String influencerFieldName = inf.getInfluencerFieldName(); for (String fieldValue : inf.getInfluencerFieldValues()) { - addInputFieldsToMap(result, fieldName, fieldValue); + addInputFieldsToMap(result, influencerFieldName, fieldValue); } } } return result; } - private void addInputFieldsToMap(Map> inputFields, String fieldName, String fieldValue) { - if (Strings.isNullOrEmpty(fieldName) == false && fieldValue != null) { - if (ReservedFieldNames.isValidFieldName(fieldName)) { - inputFields.computeIfAbsent(fieldName, k -> new LinkedHashSet<>()).add(fieldValue); + private void addInputFieldsToMap(Map> inputFields, String inputFieldName, String fieldValue) { + if (Strings.isNullOrEmpty(inputFieldName) == false && fieldValue != null) { + if (ReservedFieldNames.isValidFieldName(inputFieldName)) { + inputFields.computeIfAbsent(inputFieldName, k -> new LinkedHashSet<>()).add(fieldValue); } } } @@ -509,8 +509,8 @@ public boolean isInterim() { return isInterim; } - public void setInterim(boolean isInterim) { - this.isInterim = isInterim; + public void setInterim(boolean interim) { + this.isInterim = interim; } public String getFieldName() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java index 91a9635660977..92600df4f0569 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java @@ -272,8 +272,8 @@ public boolean isInterim() { return isInterim; } - public void setInterim(boolean isInterim) { - this.isInterim = isInterim; + public void setInterim(boolean interim) { + this.isInterim = interim; } public long getProcessingTimeMs() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ForecastRequestStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ForecastRequestStats.java index 21797baa4f8e9..3c0ceb64b5111 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ForecastRequestStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ForecastRequestStats.java @@ -264,8 +264,8 @@ public void setMessages(List messages) { this.messages = messages; } - public void setTimeStamp(Instant timestamp) { - this.timestamp = Instant.ofEpochMilli(timestamp.toEpochMilli()); + public void setTimeStamp(Instant timeStamp) { + this.timestamp = Instant.ofEpochMilli(timeStamp.toEpochMilli()); } public Instant getTimestamp() { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java index b3cc04c8d9d01..14392e3a98547 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java @@ -137,7 +137,7 @@ public class LocalStateCompositeXPackPlugin extends XPackPlugin protected List plugins = new ArrayList<>(); public LocalStateCompositeXPackPlugin(final Settings settings, final Path configPath) { - super(settings, configPath); + super(settings); } // Get around all the setOnce nonsense in the plugin diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/XPackPluginTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/XPackPluginTests.java index 7d6644c5d8bd2..325f8229ae22c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/XPackPluginTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/XPackPluginTests.java @@ -86,7 +86,7 @@ public void testNodesNotReadyForXPackCustomMetadata() { } private XPackPlugin createXPackPlugin(Settings settings) throws Exception { - return new XPackPlugin(settings, null) { + return new XPackPlugin(settings) { @Override protected void setSslService(SSLService sslService) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java index dc77aabbdc075..00d5f3d9aa69f 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java @@ -16,7 +16,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; @@ -120,7 +119,7 @@ public void testSerialization() throws IOException { } original.writeTo(out); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput in = new NamedWriteableAwareStreamInput(ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), registry); in.setVersion(out.getVersion()); final PutRoleRequest copy = new PutRoleRequest(in); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesRequestTests.java index 87a9adb4ac7dd..7e59255d7121c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesRequestTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.XPackClientPlugin; @@ -32,7 +31,7 @@ public void testSerialization() throws IOException { final BytesStreamOutput out = new BytesStreamOutput(); original.writeTo(out); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput in = new NamedWriteableAwareStreamInput(ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), registry); final GetUserPrivilegesRequest copy = new GetUserPrivilegesRequest(in); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java index 14f9e8d7a9c7c..b1906589c28b0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.test.ESTestCase; @@ -49,7 +48,7 @@ public void testSerialization() throws IOException { final BytesStreamOutput out = new BytesStreamOutput(); original.writeTo(out); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput in = new NamedWriteableAwareStreamInput(ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), registry); final GetUserPrivilegesResponse copy = new GetUserPrivilegesResponse(in); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java index 1e00f0e7c0a60..dda3407337399 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java @@ -134,7 +134,7 @@ public void testWriteAndReadFromStream() throws Exception { ExpressionParser.writeExpression(exprSource, out); final Settings settings = Settings.builder().put("path.home", createTempDir()).build(); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(settings).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); final NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry); final RoleMapperExpression exprResult = ExpressionParser.readExpression(input); assertThat(json(exprResult), equalTo(json.replaceAll("\\s", ""))); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ConfigurableClusterPrivilegesTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ConfigurableClusterPrivilegesTests.java index 509d8fecf7780..034a035f12cbf 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ConfigurableClusterPrivilegesTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ConfigurableClusterPrivilegesTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.ToXContent; @@ -34,7 +33,7 @@ public void testSerialization() throws Exception { final ConfigurableClusterPrivilege[] original = buildSecurityPrivileges(); try (BytesStreamOutput out = new BytesStreamOutput()) { ConfigurableClusterPrivileges.writeArray(out, original); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); try (StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry)) { final ConfigurableClusterPrivilege[] copy = ConfigurableClusterPrivileges.readArray(in); assertThat(copy, equalTo(original)); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ManageApplicationPrivilegesTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ManageApplicationPrivilegesTests.java index 8e3936a96fc56..e396460e88f79 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ManageApplicationPrivilegesTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ManageApplicationPrivilegesTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.EqualsHashCodeTestUtils; @@ -50,7 +49,7 @@ public void testSerialization() throws Exception { final ManageApplicationPrivileges original = buildPrivileges(); try (BytesStreamOutput out = new BytesStreamOutput()) { original.writeTo(out); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); try (StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry)) { final ManageApplicationPrivileges copy = ManageApplicationPrivileges.createFrom(in); assertThat(copy, equalTo(original)); diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/AbstractEnrichProcessor.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/AbstractEnrichProcessor.java index 2e4af805d9de3..5b4829c18c006 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/AbstractEnrichProcessor.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/AbstractEnrichProcessor.java @@ -63,8 +63,8 @@ protected AbstractEnrichProcessor( public void execute(IngestDocument ingestDocument, BiConsumer handler) { try { // If a document does not have the enrich key, return the unchanged document - String field = ingestDocument.renderTemplate(this.field); - final Object value = ingestDocument.getFieldValue(field, Object.class, ignoreMissing); + String renderedField = ingestDocument.renderTemplate(this.field); + final Object value = ingestDocument.getFieldValue(renderedField, Object.class, ignoreMissing); if (value == null) { handler.accept(ingestDocument, null); return; @@ -98,18 +98,18 @@ public void execute(IngestDocument ingestDocument, BiConsumer firstDocument = searchHits[0].getSourceAsMap(); - ingestDocument.setFieldValue(targetField, firstDocument); + ingestDocument.setFieldValue(renderedTargetField, firstDocument); } else { List> enrichDocuments = new ArrayList<>(searchHits.length); for (SearchHit searchHit : searchHits) { Map enrichDocument = searchHit.getSourceAsMap(); enrichDocuments.add(enrichDocument); } - ingestDocument.setFieldValue(targetField, enrichDocuments); + ingestDocument.setFieldValue(renderedTargetField, enrichDocuments); } } handler.accept(ingestDocument, null); diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java index a6d1ab15245ec..4fcefdabccefc 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java @@ -168,7 +168,7 @@ protected XPackLicenseState getLicenseState() { @Override public List getRestHandlers( - Settings settings, + Settings unused, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, @@ -260,7 +260,7 @@ public List> getSettings() { } @Override - public Collection getSystemIndexDescriptors(Settings settings) { + public Collection getSystemIndexDescriptors(Settings unused) { return Collections.singletonList( new SystemIndexDescriptor(ENRICH_INDEX_PATTERN, "Contains data to support enrich ingest processors.") ); diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java index e0b5dbd5e2b8a..1d6df6e1643b6 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java @@ -246,20 +246,20 @@ private static void validateField(Map properties, String fieldName, boolea } } - private XContentBuilder resolveEnrichMapping(final EnrichPolicy policy, final List> mappings) { - if (EnrichPolicy.MATCH_TYPE.equals(policy.getType())) { + private XContentBuilder resolveEnrichMapping(final EnrichPolicy enrichPolicy, final List> mappings) { + if (EnrichPolicy.MATCH_TYPE.equals(enrichPolicy.getType())) { return createEnrichMappingBuilder((builder) -> builder.field("type", "keyword").field("doc_values", false)); - } else if (EnrichPolicy.RANGE_TYPE.equals(policy.getType())) { - return createRangeEnrichMappingBuilder(policy, mappings); - } else if (EnrichPolicy.GEO_MATCH_TYPE.equals(policy.getType())) { + } else if (EnrichPolicy.RANGE_TYPE.equals(enrichPolicy.getType())) { + return createRangeEnrichMappingBuilder(enrichPolicy, mappings); + } else if (EnrichPolicy.GEO_MATCH_TYPE.equals(enrichPolicy.getType())) { return createEnrichMappingBuilder((builder) -> builder.field("type", "geo_shape")); } else { - throw new ElasticsearchException("Unrecognized enrich policy type [{}]", policy.getType()); + throw new ElasticsearchException("Unrecognized enrich policy type [{}]", enrichPolicy.getType()); } } - private XContentBuilder createRangeEnrichMappingBuilder(EnrichPolicy policy, List> mappings) { - String matchFieldPath = "properties." + policy.getMatchField().replace(".", ".properties."); + private XContentBuilder createRangeEnrichMappingBuilder(EnrichPolicy enrichPolicy, List> mappings) { + String matchFieldPath = "properties." + enrichPolicy.getMatchField().replace(".", ".properties."); List> matchFieldMappings = mappings.stream() .map(map -> ObjectPath.>eval(matchFieldPath, map)) .filter(Objects::nonNull) @@ -295,15 +295,15 @@ private XContentBuilder createRangeEnrichMappingBuilder(EnrichPolicy policy, Lis } throw new ElasticsearchException( "Multiple distinct date format specified for match field '{}' - indices({}) format entries({})", - policy.getMatchField(), - Strings.collectionToCommaDelimitedString(policy.getIndices()), + enrichPolicy.getMatchField(), + Strings.collectionToCommaDelimitedString(enrichPolicy.getIndices()), (formatEntries.contains(null) ? "(DEFAULT), " : "") + Strings.collectionToCommaDelimitedString(formatEntries) ); default: throw new ElasticsearchException( "Field '{}' has type [{}] which doesn't appear to be a range type", - policy.getMatchField(), + enrichPolicy.getMatchField(), type ); } @@ -311,14 +311,14 @@ private XContentBuilder createRangeEnrichMappingBuilder(EnrichPolicy policy, Lis if (types.isEmpty()) { throw new ElasticsearchException( "No mapping type found for match field '{}' - indices({})", - policy.getMatchField(), - Strings.collectionToCommaDelimitedString(policy.getIndices()) + enrichPolicy.getMatchField(), + Strings.collectionToCommaDelimitedString(enrichPolicy.getIndices()) ); } throw new ElasticsearchException( "Multiple distinct mapping types for match field '{}' - indices({}) types({})", - policy.getMatchField(), - Strings.collectionToCommaDelimitedString(policy.getIndices()), + enrichPolicy.getMatchField(), + Strings.collectionToCommaDelimitedString(enrichPolicy.getIndices()), Strings.collectionToCommaDelimitedString(types) ); } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/execution/assembler/Criterion.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/execution/assembler/Criterion.java index 53779d6382897..283a9449e91a9 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/execution/assembler/Criterion.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/execution/assembler/Criterion.java @@ -93,12 +93,15 @@ public Ordinal ordinal(SearchHit hit) { tbreaker = (Comparable) tb; } - Object implicitTbreaker = implicitTiebreaker.extract(hit); - if (implicitTbreaker instanceof Number == false) { - throw new EqlIllegalArgumentException("Expected _shard_doc/implicit tiebreaker as long but got [{}]", implicitTbreaker); + Object extractedImplicitTiebreaker = implicitTiebreaker.extract(hit); + if (extractedImplicitTiebreaker instanceof Number == false) { + throw new EqlIllegalArgumentException( + "Expected _shard_doc/implicit tiebreaker as long but got [{}]", + extractedImplicitTiebreaker + ); } - long implicitTiebreaker = ((Number) implicitTbreaker).longValue(); - return new Ordinal((Timestamp) ts, tbreaker, implicitTiebreaker); + long implicitTiebreakerValue = ((Number) extractedImplicitTiebreaker).longValue(); + return new Ordinal((Timestamp) ts, tbreaker, implicitTiebreakerValue); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/expression/function/scalar/string/StringContainsFunctionPipe.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/expression/function/scalar/string/StringContainsFunctionPipe.java index b1ab0854e5a46..d0fcb1fa2ac28 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/expression/function/scalar/string/StringContainsFunctionPipe.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/expression/function/scalar/string/StringContainsFunctionPipe.java @@ -54,8 +54,8 @@ public boolean resolved() { return string.resolved() && substring.resolved(); } - protected StringContainsFunctionPipe replaceChildren(Pipe string, Pipe substring) { - return new StringContainsFunctionPipe(source(), expression(), string, substring, caseInsensitive); + protected StringContainsFunctionPipe replaceChildren(Pipe pipeString, Pipe pipeSubstring) { + return new StringContainsFunctionPipe(source(), expression(), pipeString, pipeSubstring, caseInsensitive); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Join.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Join.java index 0fb681b72a331..a34279c893649 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Join.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Join.java @@ -125,8 +125,8 @@ public OrderDirection direction() { return direction; } - public Join with(List queries, KeyedFilter until, OrderDirection direction) { - return new Join(source(), queries, until, timestamp, tiebreaker, direction); + public Join with(List keyedFilterQueries, KeyedFilter untilFilter, OrderDirection orderDirection) { + return new Join(source(), keyedFilterQueries, untilFilter, timestamp, tiebreaker, orderDirection); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/EsQueryExec.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/EsQueryExec.java index cedd4ec8d035c..4ffbd499cd159 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/EsQueryExec.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/EsQueryExec.java @@ -43,8 +43,8 @@ protected NodeInfo info() { return NodeInfo.create(this, EsQueryExec::new, output, queryContainer); } - public EsQueryExec with(QueryContainer queryContainer) { - return new EsQueryExec(source(), output, queryContainer); + public EsQueryExec with(QueryContainer container) { + return new EsQueryExec(source(), output, container); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/SequenceExec.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/SequenceExec.java index 42e383d6a39c7..953560eabc61e 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/SequenceExec.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/physical/SequenceExec.java @@ -112,8 +112,8 @@ public OrderDirection direction() { return direction; } - public SequenceExec with(Limit limit) { - return new SequenceExec(source(), children(), keys(), timestamp(), tiebreaker(), limit, direction, maxSpan); + public SequenceExec with(Limit limitValue) { + return new SequenceExec(source(), children(), keys(), timestamp(), tiebreaker(), limitValue, direction, maxSpan); } @Override diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/querydsl/container/QueryContainer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/querydsl/container/QueryContainer.java index 93ad7dd9264ca..b3466d7d82a3e 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/querydsl/container/QueryContainer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/querydsl/container/QueryContainer.java @@ -101,8 +101,8 @@ public QueryContainer with(Query q) { return new QueryContainer(q, fields, attributes, sort, trackHits, includeFrozen, limit); } - public QueryContainer with(Limit limit) { - return new QueryContainer(query, fields, attributes, sort, trackHits, includeFrozen, limit); + public QueryContainer with(Limit limitValue) { + return new QueryContainer(query, fields, attributes, sort, trackHits, includeFrozen, limitValue); } public QueryContainer addColumn(Attribute attr) { diff --git a/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java b/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java index 08931c557ef83..0ce6ee7eb01a5 100644 --- a/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java +++ b/x-pack/plugin/identity-provider/src/internalClusterTest/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderIndexTests.java @@ -83,7 +83,6 @@ public void testWriteAndFindServiceProvidersFromIndex() { final int count = randomIntBetween(3, 5); List documents = new ArrayList<>(count); - final ClusterService clusterService = super.getInstanceFromNode(ClusterService.class); // Install the template assertTrue("Template should have been installed", installTemplate()); // No need to install it again diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java index a4e351ab24bad..9cf64e1d9e48c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java @@ -331,7 +331,7 @@ public void testSerialization() throws Exception { output.setVersion(version); original.writeTo(output); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput streamInput = new NamedWriteableAwareStreamInput( ByteBufferStreamInput.wrap(BytesReference.toBytes(output.bytes())), registry @@ -349,7 +349,7 @@ public void testSerializationPreV71() throws Exception { output.setVersion(version); original.writeTo(output); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput streamInput = new NamedWriteableAwareStreamInput( ByteBufferStreamInput.wrap(BytesReference.toBytes(output.bytes())), registry diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java index 321ae550dd7b7..a4916e5548ed5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java @@ -16,7 +16,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TestMatchers; import org.elasticsearch.test.VersionUtils; @@ -285,7 +284,7 @@ public void testSerializationForCurrentVersion() throws Exception { null ); descriptor.writeTo(output); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(Settings.EMPTY).getNamedWriteables()); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables()); StreamInput streamInput = new NamedWriteableAwareStreamInput( ByteBufferStreamInput.wrap(BytesReference.toBytes(output.bytes())), registry diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetadataSerializationTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetadataSerializationTests.java index b140227a5c155..3be81d6883355 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetadataSerializationTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetadataSerializationTests.java @@ -84,10 +84,8 @@ private static WatcherMetadata getWatcherMetadataFromXContent(XContentParser par @Override protected NamedXContentRegistry xContentRegistry() { return new NamedXContentRegistry( - Stream.concat( - new XPackClientPlugin(Settings.builder().put("path.home", createTempDir()).build()).getNamedXContent().stream(), - ClusterModule.getNamedXWriteables().stream() - ).collect(Collectors.toList()) + Stream.concat(new XPackClientPlugin().getNamedXContent().stream(), ClusterModule.getNamedXWriteables().stream()) + .collect(Collectors.toList()) ); }