Replacing StringBuffer with lock-free StringBuilder
Closes gh-5727
This commit is contained in:
parent
1da9e4d80a
commit
64989ae192
|
|
@ -74,7 +74,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||||
@Override
|
@Override
|
||||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||||
AnnotatedTypeMetadata metadata) {
|
AnnotatedTypeMetadata metadata) {
|
||||||
StringBuffer matchMessage = new StringBuffer();
|
StringBuilder matchMessage = new StringBuilder();
|
||||||
if (metadata.isAnnotated(ConditionalOnBean.class.getName())) {
|
if (metadata.isAnnotated(ConditionalOnBean.class.getName())) {
|
||||||
BeanSearchSpec spec = new BeanSearchSpec(context, metadata,
|
BeanSearchSpec spec = new BeanSearchSpec(context, metadata,
|
||||||
ConditionalOnBean.class);
|
ConditionalOnBean.class);
|
||||||
|
|
@ -83,8 +83,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||||
return ConditionOutcome
|
return ConditionOutcome
|
||||||
.noMatch("@ConditionalOnBean " + spec + " found no beans");
|
.noMatch("@ConditionalOnBean " + spec + " found no beans");
|
||||||
}
|
}
|
||||||
matchMessage.append(
|
matchMessage.append("@ConditionalOnBean ").append(spec)
|
||||||
"@ConditionalOnBean " + spec + " found the following " + matching);
|
.append(" found the following ").append(matching);
|
||||||
}
|
}
|
||||||
if (metadata.isAnnotated(ConditionalOnSingleCandidate.class.getName())) {
|
if (metadata.isAnnotated(ConditionalOnSingleCandidate.class.getName())) {
|
||||||
BeanSearchSpec spec = new SingleCandidateBeanSearchSpec(context, metadata,
|
BeanSearchSpec spec = new SingleCandidateBeanSearchSpec(context, metadata,
|
||||||
|
|
@ -99,8 +99,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||||
+ " found no primary candidate amongst the" + " following "
|
+ " found no primary candidate amongst the" + " following "
|
||||||
+ matching);
|
+ matching);
|
||||||
}
|
}
|
||||||
matchMessage.append("@ConditionalOnSingleCandidate " + spec + " found "
|
matchMessage.append("@ConditionalOnSingleCandidate ").append(spec)
|
||||||
+ "a primary candidate amongst the following " + matching);
|
.append(" found a primary candidate amongst the following ").append(matching);
|
||||||
}
|
}
|
||||||
if (metadata.isAnnotated(ConditionalOnMissingBean.class.getName())) {
|
if (metadata.isAnnotated(ConditionalOnMissingBean.class.getName())) {
|
||||||
BeanSearchSpec spec = new BeanSearchSpec(context, metadata,
|
BeanSearchSpec spec = new BeanSearchSpec(context, metadata,
|
||||||
|
|
@ -111,7 +111,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||||
+ " found the following " + matching);
|
+ " found the following " + matching);
|
||||||
}
|
}
|
||||||
matchMessage.append(matchMessage.length() == 0 ? "" : " ");
|
matchMessage.append(matchMessage.length() == 0 ? "" : " ");
|
||||||
matchMessage.append("@ConditionalOnMissingBean " + spec + " found no beans");
|
matchMessage.append("@ConditionalOnMissingBean ").append(spec)
|
||||||
|
.append(" found no beans");
|
||||||
}
|
}
|
||||||
return ConditionOutcome.match(matchMessage.toString());
|
return ConditionOutcome.match(matchMessage.toString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class OnClassCondition extends SpringBootCondition {
|
||||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||||
AnnotatedTypeMetadata metadata) {
|
AnnotatedTypeMetadata metadata) {
|
||||||
|
|
||||||
StringBuffer matchMessage = new StringBuffer();
|
StringBuilder matchMessage = new StringBuilder();
|
||||||
|
|
||||||
MultiValueMap<String, Object> onClasses = getAttributes(metadata,
|
MultiValueMap<String, Object> onClasses = getAttributes(metadata,
|
||||||
ConditionalOnClass.class);
|
ConditionalOnClass.class);
|
||||||
|
|
@ -56,8 +56,8 @@ class OnClassCondition extends SpringBootCondition {
|
||||||
.noMatch("required @ConditionalOnClass classes not found: "
|
.noMatch("required @ConditionalOnClass classes not found: "
|
||||||
+ StringUtils.collectionToCommaDelimitedString(missing));
|
+ StringUtils.collectionToCommaDelimitedString(missing));
|
||||||
}
|
}
|
||||||
matchMessage.append("@ConditionalOnClass classes found: "
|
matchMessage.append("@ConditionalOnClass classes found: ")
|
||||||
+ StringUtils.collectionToCommaDelimitedString(
|
.append(StringUtils.collectionToCommaDelimitedString(
|
||||||
getMatchingClasses(onClasses, MatchType.PRESENT, context)));
|
getMatchingClasses(onClasses, MatchType.PRESENT, context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,9 +72,9 @@ class OnClassCondition extends SpringBootCondition {
|
||||||
+ StringUtils.collectionToCommaDelimitedString(present));
|
+ StringUtils.collectionToCommaDelimitedString(present));
|
||||||
}
|
}
|
||||||
matchMessage.append(matchMessage.length() == 0 ? "" : " ");
|
matchMessage.append(matchMessage.length() == 0 ? "" : " ");
|
||||||
matchMessage.append("@ConditionalOnMissing classes not found: "
|
matchMessage.append("@ConditionalOnMissing classes not found: ")
|
||||||
+ StringUtils.collectionToCommaDelimitedString(getMatchingClasses(
|
.append(StringUtils.collectionToCommaDelimitedString(getMatchingClasses(
|
||||||
onMissingClasses, MatchType.MISSING, context)));
|
onMissingClasses, MatchType.MISSING, context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConditionOutcome.match(matchMessage.toString());
|
return ConditionOutcome.match(matchMessage.toString());
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,8 @@ class OnPropertyCondition extends SpringBootCondition {
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder("@ConditionalOnProperty ");
|
StringBuilder message = new StringBuilder("@ConditionalOnProperty ");
|
||||||
if (!missingProperties.isEmpty()) {
|
if (!missingProperties.isEmpty()) {
|
||||||
message.append("missing required properties "
|
message.append("missing required properties ").append(expandNames(prefix, missingProperties))
|
||||||
+ expandNames(prefix, missingProperties) + " ");
|
.append(" ");
|
||||||
}
|
}
|
||||||
if (!nonMatchingProperties.isEmpty()) {
|
if (!nonMatchingProperties.isEmpty()) {
|
||||||
String expected = StringUtils.hasLength(havingValue) ? havingValue : "!false";
|
String expected = StringUtils.hasLength(havingValue) ? havingValue : "!false";
|
||||||
|
|
@ -113,7 +113,7 @@ class OnPropertyCondition extends SpringBootCondition {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String expandNames(String prefix, List<String> names) {
|
private String expandNames(String prefix, List<String> names) {
|
||||||
StringBuffer expanded = new StringBuffer();
|
StringBuilder expanded = new StringBuilder();
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
expanded.append(expanded.length() == 0 ? "" : ", ");
|
expanded.append(expanded.length() == 0 ? "" : ", ");
|
||||||
expanded.append(prefix);
|
expanded.append(prefix);
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ public class CommandCompleter extends StringsCompleter {
|
||||||
private final String usage;
|
private final String usage;
|
||||||
|
|
||||||
OptionHelpLine(OptionHelp optionHelp) {
|
OptionHelpLine(OptionHelp optionHelp) {
|
||||||
StringBuffer options = new StringBuffer();
|
StringBuilder options = new StringBuilder();
|
||||||
for (String option : optionHelp.getOptions()) {
|
for (String option : optionHelp.getOptions()) {
|
||||||
options.append(options.length() == 0 ? "" : ", ");
|
options.append(options.length() == 0 ? "" : ", ");
|
||||||
options.append(option);
|
options.append(option);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class ConnectionInputStream extends FilterInputStream {
|
||||||
*/
|
*/
|
||||||
public String readHeader() throws IOException {
|
public String readHeader() throws IOException {
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
StringBuffer content = new StringBuffer(BUFFER_SIZE);
|
StringBuilder content = new StringBuilder(BUFFER_SIZE);
|
||||||
while (content.indexOf(HEADER_END) == -1) {
|
while (content.indexOf(HEADER_END) == -1) {
|
||||||
int amountRead = checkedRead(buffer, 0, BUFFER_SIZE);
|
int amountRead = checkedRead(buffer, 0, BUFFER_SIZE);
|
||||||
content.append(new String(buffer, 0, amountRead));
|
content.append(new String(buffer, 0, amountRead));
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logArguments(String message, String[] args) {
|
private void logArguments(String message, String[] args) {
|
||||||
StringBuffer sb = new StringBuffer(message);
|
StringBuilder sb = new StringBuilder(message);
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
sb.append(arg).append(" ");
|
sb.append(arg).append(" ");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue