Avoid regex pattern matching for simple String replacement steps

Issue: SPR-17279
This commit is contained in:
Juergen Hoeller
2018-09-17 14:22:19 +02:00
parent cc87fbcb7f
commit 34663300a6
13 changed files with 61 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -183,7 +183,7 @@ public class DateTimeFormatterFactory {
// Using strict parsing to align with Joda-Time and standard DateFormat behavior:
// otherwise, an overflow like e.g. Feb 29 for a non-leap-year wouldn't get rejected.
// However, with strict parsing, a year digit needs to be specified as 'u'...
String patternToUse = this.pattern.replace("yy", "uu");
String patternToUse = StringUtils.replace(this.pattern, "yy", "uu");
dateTimeFormatter = DateTimeFormatter.ofPattern(patternToUse).withResolverStyle(ResolverStyle.STRICT);
}
else if (this.iso != null && this.iso != ISO.NONE) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.List;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* ClassFileTransformer-based weaver, allowing for a list of transformers to be
@@ -73,7 +74,7 @@ public class WeavingTransformer {
* @return (possibly transformed) class byte definition
*/
public byte[] transformIfNecessary(String className, byte[] bytes) {
String internalName = className.replace(".", "/");
String internalName = StringUtils.replace(className, ".", "/");
return transformIfNecessary(className, internalName, bytes, null);
}