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 290e922808b84..4e47ac39be6bf 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 74434adf61fbb..f9c1ae768e763 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 @@ -537,7 +537,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 b265dd5e44710..29be367cceaf2 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 @@ -127,7 +127,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 ); @@ -147,7 +147,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 282fa6c8960cd..28021b3c03269 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 @@ -87,7 +87,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"; @@ -112,7 +112,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/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 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 7618135c8662f..d359ba7001749 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 @@ -295,7 +295,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 @@ -382,7 +382,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 2f45bafe493bb..b0528e7e9802c 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 fd24fd7c0faba..2ab0420e4f9aa 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 @@ -459,24 +459,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)); @@ -534,4 +541,8 @@ static ActionListener cancelTransformTasksListener( } }); } + + private static String optionalSpace(boolean spaceNeeded) { + return spaceNeeded ? " " : ""; + } }