Consistent use of StringUtils.toStringArray

This commit is contained in:
Juergen Hoeller
2018-02-16 19:48:43 +01:00
parent 350f318d2e
commit 6d11b40353
27 changed files with 125 additions and 137 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -57,6 +57,7 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors;
@@ -205,7 +206,7 @@ public class HandlerMethodInvoker {
Map<String, Object> model = (mavModel != null ? mavModel : implicitModel);
if (model != null) {
try {
String[] originalAttrNames = model.keySet().toArray(new String[model.size()]);
String[] originalAttrNames = StringUtils.toStringArray(model.keySet());
for (String attrName : originalAttrNames) {
Object attrValue = model.get(attrName);
boolean isSessionAttr = this.methodResolver.isSessionAttribute(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -215,7 +215,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
logger.info("Scanning base packages: [" +
StringUtils.collectionToCommaDelimitedString(this.basePackages) + "]");
}
scanner.scan(this.basePackages.toArray(new String[this.basePackages.size()]));
scanner.scan(StringUtils.toStringArray(this.basePackages));
}
String[] configLocations = getConfigLocations();

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.
@@ -42,6 +42,7 @@ import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
/**
* {@link javax.servlet.Filter} that makes form encoded data available through
@@ -168,13 +169,13 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter {
return parameterValues;
}
if (parameterValues == null || getQueryString() == null) {
return formParam.toArray(new String[formParam.size()]);
return StringUtils.toStringArray(formParam);
}
else {
List<String> result = new ArrayList<String>(parameterValues.length + formParam.size());
result.addAll(Arrays.asList(parameterValues));
result.addAll(formParam);
return result.toArray(new String[result.size()]);
return StringUtils.toStringArray(result);
}
}
}

View File

@@ -773,7 +773,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
builder.pathSegment(getPathSegments().toArray(new String[getPathSegments().size()]));
builder.pathSegment(StringUtils.toStringArray(getPathSegments()));
}
@Override