Use String#replace instead of String#replaceAll where appropriate

Avoid using String#replaceAll when the pattern is not a regular
expression.

Using java.lang.String#replace(CharSequence, CharSequence) will
improve performance.

Closes gh-36678

Signed-off-by: shenjianeng <ishenjianeng@qq.com>
This commit is contained in:
shenjianeng
2026-05-03 14:34:01 +02:00
committed by GitHub
parent d9ecf945cc
commit 27bdf24482
2 changed files with 4 additions and 4 deletions
@@ -568,8 +568,8 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
private String locationToString(List<Resource> locations) {
return locations.toString()
.replaceAll("class path resource", "classpath")
.replaceAll("ServletContext resource", "ServletContext");
.replace("class path resource", "classpath")
.replace("ServletContext resource", "ServletContext");
}
}
@@ -714,8 +714,8 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
private String locationToString(List<Resource> locations) {
return locations.toString()
.replaceAll("class path resource", "classpath")
.replaceAll("ServletContext resource", "ServletContext");
.replace("class path resource", "classpath")
.replace("ServletContext resource", "ServletContext");
}
}