diff --git a/docs/changelog/127475.yaml b/docs/changelog/127475.yaml new file mode 100644 index 0000000000000..0398fda30b014 --- /dev/null +++ b/docs/changelog/127475.yaml @@ -0,0 +1,5 @@ +pr: 127475 +summary: Remove dangling spaces wherever found +area: Security +type: bug +issues: [] diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java index b28e883476bce..a551515a5261c 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java @@ -333,8 +333,11 @@ private void throwExpectedStartObject(XContentParser parser, XContentParser.Toke private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); - for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); + for (int i = 0; i < requiredFields.size(); i++) { + if (i > 0) { + message.append(" "); + } + message.append("Required one of fields ").append(Arrays.toString(requiredFields.get(i))).append(", but none were specified."); } throw new IllegalArgumentException(message.toString()); } diff --git a/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java index e4feaa18365f1..60621cbf14357 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java @@ -1004,7 +1004,7 @@ public void testMultipleRequiredFieldSet() throws IOException { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> objectParser.apply(parser, null)); assertThat( e.getMessage(), - equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified. ") + equalTo("Required one of fields [a, b], but none were specified. " + "Required one of fields [c, d], but none were specified.") ); } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java index 6b0f780a886a1..1f9cdc12c7caa 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java @@ -299,7 +299,7 @@ static void updateShardAllocationStatus( NAME, "increase_shard_limit_index_setting", "Elasticsearch isn't allowed to allocate some shards from these indices to any data nodes because each node has reached the index " - + "shard limit. ", + + "shard limit.", "Increase the values for the [" + INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] index setting on each index or add more nodes to the target tiers.", @@ -316,7 +316,7 @@ static void updateShardAllocationStatus( "increase_shard_limit_index_setting:tier:" + tier, "Elasticsearch isn't allowed to allocate some shards from these indices because each node in the [" + tier - + "] tier has reached the index shard limit. ", + + "] tier has reached the index shard limit.", "Increase the values for the [" + INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] index setting on each index or add more nodes to the target tiers.", @@ -347,7 +347,7 @@ static void updateShardAllocationStatus( "increase_shard_limit_cluster_setting:tier:" + tier, "Elasticsearch isn't allowed to allocate some shards from these indices because each node in the [" + tier - + "] tier has reached the cluster shard limit. ", + + "] tier has reached the cluster shard limit.", "Increase the values for the [" + CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + "] cluster setting or add more nodes to the target tiers.", @@ -395,7 +395,7 @@ static void updateShardAllocationStatus( NAME, "migrate_data_tiers_include_data", "Elasticsearch isn't allowed to allocate some shards from these indices to any nodes in the desired data tiers because the " - + "indices are configured with allocation filter rules that are incompatible with the nodes in this tier. ", + + "indices are configured with allocation filter rules that are incompatible with the nodes in this tier.", "Remove [" + INDEX_ROUTING_INCLUDE_GROUP_PREFIX + ".data] from the index settings or try migrating to data tiers by first stopping ILM [POST /_ilm/stop] and then using " diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java index ada84c98be00b..be0199fc8ba30 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/CommandLineHttpClient.java @@ -277,7 +277,7 @@ public void checkClusterHealthWithRetriesWaitingForCluster(String username, Secu checkClusterHealthWithRetriesWaitingForCluster(username, password, retries); return; } else { - throw new IllegalStateException("Failed to determine the health of the cluster. ", e); + throw new IllegalStateException("Failed to determine the health of the cluster.", e); } } final int responseStatus = response.getHttpStatus(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index 1d126e3030d2a..7a07eb18d2deb 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -542,7 +542,7 @@ private static Map initializeReservedRoles() { + "This role grants monitor_ml cluster privileges, read access to the .ml-notifications and .ml-anomalies* indices " + "(which store machine learning results), and write access to .ml-annotations* indices. " + "Machine learning users also need index privileges for source and destination indices " - + "and roles that grant access to Kibana. " + + "and roles that grant access to Kibana." ) ), entry( diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 726c381eb1f85..458613217de6c 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -213,7 +213,7 @@ static DeprecationIssue checkMultipleDataPaths( "Specifying multiple data paths is deprecated", "https://ela.st/es-deprecation-7-multiple-paths", "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ", + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.", false, null ); @@ -233,7 +233,7 @@ static DeprecationIssue checkDataPathsList( "Multiple data paths are not supported", "https://ela.st/es-deprecation-7-multiple-paths", "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. ", + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0.", false, null ); diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 85c91e4f9a127..bb94298726996 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -112,7 +112,7 @@ public void testMultipleDataPaths() { issue.getDetails(), equalTo( "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. " + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0." ) ); String url = "https://ela.st/es-deprecation-7-multiple-paths"; @@ -137,7 +137,7 @@ public void testDataPathsList() { issue.getDetails(), equalTo( "The [path.data] setting contains a list of paths. Specify a single path as a string. Use RAID or other system level " - + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0. " + + "features to utilize multiple disks. If multiple data paths are configured, the node will fail to start in 8.0." ) ); String url = "https://ela.st/es-deprecation-7-multiple-paths"; diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java index f989f0e8a8be3..8def025b93aff 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/analytics/event/parser/event/AnalyticsEventParserTestCase.java @@ -84,7 +84,7 @@ public void testParsingWithMissingRequiredField() throws IOException { try (XContentParser xContentParser = createXContentParser(json)) { Exception e = expectThrows(IllegalArgumentException.class, () -> parser().parse(xContentParser, context)); - assertEquals(Strings.format("Required one of fields [%s], but none were specified. ", field), e.getMessage()); + assertEquals(Strings.format("Required one of fields [%s], but none were specified.", field), e.getMessage()); } } } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java index b390a51f6d3e2..f49fde30740b5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/BaseTransportInferenceAction.java @@ -337,7 +337,7 @@ private ElasticsearchStatusException unsupportedStreamingTaskException(Request r } private static ElasticsearchStatusException unknownServiceException(String service, String inferenceId) { - return new ElasticsearchStatusException("Unknown service [{}] for model [{}]. ", RestStatus.BAD_REQUEST, service, inferenceId); + return new ElasticsearchStatusException("Unknown service [{}] for model [{}]", RestStatus.BAD_REQUEST, service, inferenceId); } private static ElasticsearchStatusException requestModelTaskTypeMismatchException(TaskType requested, TaskType expected) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java index 01e663df4a3ea..0dbbc7715fbfa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java @@ -174,7 +174,7 @@ private void parseModels(List unparsedModels, ActionListener { assertThat(e, isA(ElasticsearchException.class)); - assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "]. ")); + assertThat(e.getMessage(), is("Unknown service [" + serviceId + "] for model [" + inferenceId + "]")); assertThat(((ElasticsearchException) e).status(), is(RestStatus.BAD_REQUEST)); })); verify(inferenceStats.inferenceDuration()).record(anyLong(), assertArg(attributes -> { diff --git a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/HttpCertificateCommand.java b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/HttpCertificateCommand.java index 23a7bb96be2af..8c5dd0144ea46 100644 --- a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/HttpCertificateCommand.java +++ b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/HttpCertificateCommand.java @@ -817,7 +817,7 @@ private static boolean askCertSigningRequest(Terminal terminal) { terminal.println("A CSR is used when you want your certificate to be created by an existing"); terminal.println("Certificate Authority (CA) that you do not control (that is, you don't have"); - terminal.println("access to the keys for that CA). "); + terminal.println("access to the keys for that CA)."); terminal.println(""); terminal.println("If you are in a corporate environment with a central security team, then you"); terminal.println("may have an existing Corporate CA that can generate your certificate for you."); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index 47716eb69f528..c2fc92d905244 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -1338,7 +1338,7 @@ private void innerRefresh( ); } else { logger.info( - "failed to update the original token document [{}] after all retries, the update result was [{}]. ", + "failed to update the original token document [{}] after all retries, the update result was [{}].", tokenDoc.id(), updateResponse.getResult() ); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java index 3c7fa029d4514..be7a997741372 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java @@ -398,7 +398,7 @@ void checkElasticKeystorePasswordValid(Terminal terminal, Environment env) throw terminal.errorPrintln(""); throw new UserException( ExitCodes.CONFIG, - "Failed to establish SSL connection to elasticsearch at " + route.toString() + ". ", + "Failed to establish SSL connection to elasticsearch at " + route.toString() + ".", e ); } catch (IOException e) { @@ -557,7 +557,7 @@ private void changeUserPassword(String user, SecureString password, Terminal ter terminal.errorPrintln("* Try running this tool again."); terminal.errorPrintln("* Try running with the --verbose parameter for additional messages."); terminal.errorPrintln("* Check the elasticsearch logs for additional error details."); - terminal.errorPrintln("* Use the change password API manually. "); + terminal.errorPrintln("* Use the change password API manually."); terminal.errorPrintln(""); throw new UserException(ExitCodes.TEMP_FAILURE, "Failed to set password for user [" + user + "]."); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java index af82b9361dd3d..8d02992c2ec3a 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticator.java @@ -235,7 +235,7 @@ public void authenticate(OpenIdConnectToken token, final ActionListener logger.debug( "The Attribute Statements of SAML Response with ID [{}] contained no attributes and the SAML Assertion Subject " + "did not contain a SAML NameID. Please verify that the Identity Provider configuration with regards to attribute " - + "release is correct. ", + + "release is correct.", response.getID() ); throw samlException("Could not process any SAML attributes in {}", response.getElementQName()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java index cf1afac19084f..53906814ac931 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java @@ -305,7 +305,7 @@ static RoleDescriptor parseRoleDescriptor( Validation.Error validationError = Validation.Roles.validateRoleName(roleName, false); if (validationError != null) { logger.error( - "invalid role definition [{}] in roles file [{}]. invalid role name - {}. skipping role... ", + "invalid role definition [{}] in roles file [{}]. invalid role name - {}. skipping role...", roleName, path.toAbsolutePath(), validationError @@ -392,7 +392,7 @@ private static RoleDescriptor checkDescriptor( Validation.Error validationError = Validation.Roles.validateRoleDescription(descriptor.getDescription()); if (validationError != null) { logger.error( - "invalid role definition [{}] in roles file [{}]. invalid description - {}. skipping role... ", + "invalid role definition [{}] in roles file [{}]. invalid description - {}. skipping role...", roleName, path.toAbsolutePath(), validationError diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java index 542bbbe086cc5..db225540d113d 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java @@ -213,7 +213,7 @@ private void checkClusterHealthWithRetries( try { response = client.execute("GET", clusterHealthUrl, username, password, () -> null, CommandLineHttpClient::responseBuilder); } catch (Exception e) { - throw new UserException(ExitCodes.UNAVAILABLE, "Failed to determine the health of the cluster. ", e); + throw new UserException(ExitCodes.UNAVAILABLE, "Failed to determine the health of the cluster.", e); } final int responseStatus = response.getHttpStatus(); if (responseStatus != HttpURLConnection.HTTP_OK) { diff --git a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java index b3d21193b5915..721d5308c35e8 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ObjectParser.java @@ -261,7 +261,7 @@ private void throwFailedToParse(JsonParser parser, String currentFieldName, Exce private static void throwMissingRequiredFields(List requiredFields) { final StringBuilder message = new StringBuilder(); for (String[] fields : requiredFields) { - message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. "); + message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified."); } throw new ParseException(message.toString()); } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java index 37bd800477be6..b9929c92a0c57 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java @@ -467,24 +467,31 @@ private void waitForTransformStopped( return; } else { StringBuilder message = new StringBuilder(); + boolean lineAdded = false; if (persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Successfully stopped ["); message.append(persistentTaskIds.size() - stillRunningTasks.size() - exceptions.size()); - message.append("] transforms. "); + message.append("] transforms."); + lineAdded = true; } if (exceptions.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Could not stop the transforms "); message.append(exceptions.keySet()); - message.append(" as they were failed. Use force stop to stop the transforms. "); + message.append(" as they were failed. Use force stop to stop the transforms."); + lineAdded = true; } if (stillRunningTasks.size() > 0) { + message.append(optionalSpace(lineAdded)); message.append("Could not stop the transforms "); message.append(stillRunningTasks); message.append(" as they timed out ["); message.append(timeout.toString()); message.append("]."); + lineAdded = true; } listener.onFailure(new ElasticsearchStatusException(message.toString(), RestStatus.REQUEST_TIMEOUT)); @@ -542,4 +549,8 @@ static ActionListener cancelTransformTasksListener( } }); } + + private static String optionalSpace(boolean spaceNeeded) { + return spaceNeeded ? " " : ""; + } }