Merge pull request #31456 from dreis2211

* pr/31456:
  Use String.repeat() where possible

Closes gh-31456
pull/31462/head
Stephane Nicoll 2 years ago
commit d9d1bdf0f6

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -53,12 +53,9 @@ public class ConditionEvaluationReportMessage {
} }
private StringBuilder getLogMessage(ConditionEvaluationReport report, String title) { private StringBuilder getLogMessage(ConditionEvaluationReport report, String title) {
String separator = "=".repeat(title.length());
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
message.append(String.format("%n%n%n")); message.append(String.format("%n%n%n"));
StringBuilder separator = new StringBuilder();
for (int i = 0; i < title.length(); i++) {
separator.append("=");
}
message.append(String.format("%s%n", separator)); message.append(String.format("%s%n", separator));
message.append(String.format("%s%n", title)); message.append(String.format("%s%n", title));
message.append(String.format("%s%n%n%n", separator)); message.append(String.format("%s%n%n%n", separator));

@ -494,11 +494,7 @@ class ServerPropertiesTests {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
StringBuilder data = new StringBuilder(); body.add("data", "a".repeat(250000));
for (int i = 0; i < 250000; i++) {
data.append("a");
}
body.add("data", data.toString());
HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers); HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
template.postForEntity(URI.create("http://localhost:" + jetty.getPort() + "/form"), entity, Void.class); template.postForEntity(URI.create("http://localhost:" + jetty.getPort() + "/form"), entity, Void.class);
assertThat(failure.get()).isNotNull(); assertThat(failure.get()).isNotNull();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,9 +65,9 @@ class ServiceCapabilitiesReportGenerator {
private String generateHelp(String url, InitializrServiceMetadata metadata) { private String generateHelp(String url, InitializrServiceMetadata metadata) {
String header = "Capabilities of " + url; String header = "Capabilities of " + url;
StringBuilder report = new StringBuilder(); StringBuilder report = new StringBuilder();
report.append(repeat("=", header.length())).append(NEW_LINE); report.append("=".repeat(header.length())).append(NEW_LINE);
report.append(header).append(NEW_LINE); report.append(header).append(NEW_LINE);
report.append(repeat("=", header.length())).append(NEW_LINE); report.append("=".repeat(header.length())).append(NEW_LINE);
report.append(NEW_LINE); report.append(NEW_LINE);
reportAvailableDependencies(metadata, report); reportAvailableDependencies(metadata, report);
report.append(NEW_LINE); report.append(NEW_LINE);
@ -139,12 +139,4 @@ class ServiceCapabilitiesReportGenerator {
} }
} }
private static String repeat(String s, int count) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(s);
}
return sb.toString();
}
} }

Loading…
Cancel
Save