### CI Link

https://gradle-enterprise.elastic.co/s/323cgxy7itfky

### Repro line

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.elasticsearch.common.StringsTests.testDeleteAny" -Dtests.seed=8A64C9DD086550D3 -Dtests.locale=it -Dtests.timezone=Asia/Baghdad -Druntime.java=17	

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.timeZoneId=Europe/Rome&tests.container=org.elasticsearch.common.StringsTests&tests.test=testDeleteAny

### Failure excerpt

```
java.lang.AssertionError: |  
  | Expected: "짞ĐGⰣ*ﮢ" |  
  | but: was "짞ĐGⰣﮢ"
```
server/src/test/java/org/elasticsearch/common/StringsTests.java
} else {
            if (randomBoolean()) {
                error = false;
                toXContent = (ToXContentObject) (builder, params) -> builder.startObject()
                    .field("ok", "here")
                    .field("catastrophe", "")
                    .endObject();
            } else {
                error = true;
                toXContent = (ToXContentObject) (builder, params) -> builder.field("ok", "here").field("catastrophe", "");
            }
        }
        String toString = Strings.toString(toXContent);
        if (error) {
            assertThat(toString, containsString("\"error\":\"error building toString out of XContent:"));
            assertThat(toString, containsString("\"stack_trace\":"));
        } else {
            assertThat(toString, containsString("\"ok\":\"here\""));
            assertThat(toString, containsString("\"catastrophe\":\"\""));
        }
    }
    public void testToStringToXContentWithOrWithoutParams() {
        ToXContent toXContent = (builder, params) -> builder.field("color_from_param", params.param("color", "red"));
        
        assertThat(Strings.toString(toXContent), containsString("\"color_from_param\":\"red\""));
        
        assertThat(
            Strings.toString(toXContent, new ToXContent.MapParams(Collections.singletonMap("color", "blue"))),
            containsString("\"color_from_param\":\"blue\"")
        );