Skip to content

Commit d58f38f

Browse files
dreis2211snicoll
authored andcommitted
Use String.replace() with single char if possible
See gh-8089
1 parent 551bfb2 commit d58f38f

File tree

19 files changed

+23
-23
lines changed

19 files changed

+23
-23
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public Object invoke(HttpServletRequest request) {
139139
private HttpStatus getStatus(Health health) {
140140
String code = health.getStatus().getCode();
141141
if (code != null) {
142-
code = code.toLowerCase().replace("_", "-");
142+
code = code.toLowerCase().replace('_', '-');
143143
for (String candidate : RelaxedNames.forCamelCase(code)) {
144144
HttpStatus status = this.statusMapping.get(candidate);
145145
if (status != null) {

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
5050
}
5151
CacheType cacheType = CacheConfigurations
5252
.getType(((AnnotationMetadata) metadata).getClassName());
53-
String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
53+
String value = resolver.getProperty("type").replace('-', '_').toUpperCase();
5454
if (value.equals(cacheType.name())) {
5555
return ConditionOutcome.match(message.because(value + " cache type"));
5656
}

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4545
return ConditionOutcome.noMatch(
4646
message.didNotFind("spring.session.store-type property").atAll());
4747
}
48-
String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
48+
String value = resolver.getProperty("store-type").replace('-', '_').toUpperCase();
4949
if (value.equals(sessionStoreType.name())) {
5050
return ConditionOutcome.match(message
5151
.found("spring.session.store-type property").items(sessionStoreType));

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorViewResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public void setOrderShouldChangeOrder() throws Exception {
212212
private void setResourceLocation(String path) {
213213
String packageName = getClass().getPackage().getName();
214214
this.resourceProperties.setStaticLocations(new String[] {
215-
"classpath:" + packageName.replace(".", "/") + path + "/" });
215+
"classpath:" + packageName.replace('.', '/') + path + "/" });
216216
}
217217

218218
private MockHttpServletResponse render(ModelAndView modelAndView) throws Exception {

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ protected final void addClass(JarWriter writer, ClassLoader classLoader,
264264
if (classLoader == null) {
265265
classLoader = Thread.currentThread().getContextClassLoader();
266266
}
267-
String name = sourceClass.replace(".", "/") + ".class";
267+
String name = sourceClass.replace('.', '/') + ".class";
268268
InputStream stream = classLoader.getResourceAsStream(name);
269269
writer.writeEntry(this.layout.getClassesLocation() + name, stream);
270270
}

spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected ExtendedClassCollector(InnerLoader loader, CompilationUnit unit,
161161
protected Class<?> createClass(byte[] code, ClassNode classNode) {
162162
Class<?> createdClass = super.createClass(code, classNode);
163163
ExtendedGroovyClassLoader.this.classResources
164-
.put(classNode.getName().replace(".", "/") + ".class", code);
164+
.put(classNode.getName().replace('.', '/') + ".class", code);
165165
return createdClass;
166166
}
167167

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class RestartClassLoaderTests {
5252
private static final String PACKAGE = RestartClassLoaderTests.class.getPackage()
5353
.getName();
5454

55-
private static final String PACKAGE_PATH = PACKAGE.replace(".", "/");
55+
private static final String PACKAGE_PATH = PACKAGE.replace('.', '/');
5656

5757
private static final Charset UTF_8 = Charset.forName("UTF-8");
5858

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class DevToolsSettingsTests {
3737
public TemporaryFolder temporaryFolder = new TemporaryFolder();
3838

3939
private static final String ROOT = DevToolsSettingsTests.class.getPackage().getName()
40-
.replace(".", "/") + "/";
40+
.replace('.', '/') + "/";
4141

4242
@Test
4343
public void includePatterns() throws Exception {

spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected File getFile(Class<?> type) {
9999
}
100100

101101
public static String sourcePathFor(Class<?> type) {
102-
return type.getName().replace(".", "/") + ".java";
102+
return type.getName().replace('.', '/') + ".java";
103103
}
104104

105105
protected File getSourceFolder() {

spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void allBeanMethodsArePublic() throws IOException, ClassNotFoundException
6565
private Set<AnnotationMetadata> findConfigurationClasses() throws IOException {
6666
Set<AnnotationMetadata> configurationClasses = new HashSet<AnnotationMetadata>();
6767
Resource[] resources = this.resolver.getResources("classpath*:"
68-
+ getClass().getPackage().getName().replace(".", "/") + "/**/*.class");
68+
+ getClass().getPackage().getName().replace('.', '/') + "/**/*.class");
6969
for (Resource resource : resources) {
7070
if (!isTestClass(resource)) {
7171
MetadataReader metadataReader = new SimpleMetadataReaderFactory()

0 commit comments

Comments
 (0)