Consistent use of StringUtils.hasLength(String) vs isEmpty(Object)
This commit is contained in:
@@ -699,7 +699,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
*/
|
||||
public Set<HttpMethod> getAllow() {
|
||||
String value = getFirst(ALLOW);
|
||||
if (!StringUtils.isEmpty(value)) {
|
||||
if (StringUtils.hasLength(value)) {
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
|
||||
List<HttpMethod> result = new ArrayList<>(tokens.length);
|
||||
for (String token : tokens) {
|
||||
|
||||
@@ -74,7 +74,7 @@ class UndertowServerHttpRequest extends AbstractServerHttpRequest {
|
||||
Assert.notNull(exchange, "HttpServerExchange is required.");
|
||||
String requestURL = exchange.getRequestURL();
|
||||
String query = exchange.getQueryString();
|
||||
String requestUriAndQuery = StringUtils.isEmpty(query) ? requestURL : requestURL + "?" + query;
|
||||
String requestUriAndQuery = (StringUtils.hasLength(query) ? requestURL + "?" + query : requestURL);
|
||||
return new URI(requestUriAndQuery);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -213,8 +213,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
}
|
||||
|
||||
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.class);
|
||||
String name = (requestParam == null || StringUtils.isEmpty(requestParam.name()) ?
|
||||
parameter.getParameterName() : requestParam.name());
|
||||
String name = (requestParam != null && StringUtils.hasLength(requestParam.name()) ?
|
||||
requestParam.name() : parameter.getParameterName());
|
||||
Assert.state(name != null, "Unresolvable parameter name");
|
||||
|
||||
if (value == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -33,7 +33,6 @@ import org.springframework.util.StringUtils;
|
||||
* <p>Provides options to create {@link UriBuilder} instances with a common
|
||||
* base URI, alternative encoding mode strategies, among others.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
* @see UriComponentsBuilder
|
||||
@@ -222,31 +221,27 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
||||
|
||||
private final UriComponentsBuilder uriComponentsBuilder;
|
||||
|
||||
|
||||
public DefaultUriBuilder(String uriTemplate) {
|
||||
this.uriComponentsBuilder = initUriComponentsBuilder(uriTemplate);
|
||||
}
|
||||
|
||||
private UriComponentsBuilder initUriComponentsBuilder(String uriTemplate) {
|
||||
UriComponentsBuilder result;
|
||||
if (StringUtils.isEmpty(uriTemplate)) {
|
||||
result = baseUri != null ? baseUri.cloneBuilder() : UriComponentsBuilder.newInstance();
|
||||
if (!StringUtils.hasLength(uriTemplate)) {
|
||||
result = (baseUri != null ? baseUri.cloneBuilder() : UriComponentsBuilder.newInstance());
|
||||
}
|
||||
else if (baseUri != null) {
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uriTemplate);
|
||||
UriComponents uri = builder.build();
|
||||
result = uri.getHost() == null ? baseUri.cloneBuilder().uriComponents(uri) : builder;
|
||||
result = (uri.getHost() == null ? baseUri.cloneBuilder().uriComponents(uri) : builder);
|
||||
}
|
||||
else {
|
||||
result = UriComponentsBuilder.fromUriString(uriTemplate);
|
||||
}
|
||||
|
||||
if (encodingMode.equals(EncodingMode.TEMPLATE_AND_VALUES)) {
|
||||
result.encode();
|
||||
}
|
||||
|
||||
parsePathIfNecessary(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user