Adapt to deprecation of StringUtils.isEmpty(Object)
See gh-23774
This commit is contained in:
parent
3bfe1b00b5
commit
2d8528d5bd
|
@ -296,11 +296,11 @@ public final class ConditionMessage {
|
|||
* @return a built {@link ConditionMessage}
|
||||
*/
|
||||
public ConditionMessage because(String reason) {
|
||||
if (StringUtils.isEmpty(reason)) {
|
||||
return new ConditionMessage(ConditionMessage.this, this.condition);
|
||||
if (StringUtils.hasLength(reason)) {
|
||||
return new ConditionMessage(ConditionMessage.this,
|
||||
StringUtils.hasLength(this.condition) ? this.condition + " " + reason : reason);
|
||||
}
|
||||
return new ConditionMessage(ConditionMessage.this,
|
||||
StringUtils.isEmpty(this.condition) ? reason : this.condition + " " + reason);
|
||||
return new ConditionMessage(ConditionMessage.this, this.condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class EntityScanPackages {
|
|||
}
|
||||
if (packagesToScan.isEmpty()) {
|
||||
String packageName = ClassUtils.getPackageName(metadata.getClassName());
|
||||
Assert.state(!StringUtils.isEmpty(packageName), "@EntityScan cannot be used with the default package");
|
||||
Assert.state(StringUtils.hasLength(packageName), "@EntityScan cannot be used with the default package");
|
||||
return Collections.singleton(packageName);
|
||||
}
|
||||
return packagesToScan;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -277,10 +277,10 @@ public final class TestPropertyValues {
|
|||
}
|
||||
|
||||
private static Pair of(String name, String value) {
|
||||
if (StringUtils.isEmpty(name) && StringUtils.isEmpty(value)) {
|
||||
return null;
|
||||
if (StringUtils.hasLength(name) || StringUtils.hasLength(value)) {
|
||||
return new Pair(name, value);
|
||||
}
|
||||
return new Pair(name, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public final class TestPropertyValues {
|
|||
|
||||
private String setOrClear(String name, String value) {
|
||||
Assert.notNull(name, "Name must not be null");
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
if (!StringUtils.hasLength(value)) {
|
||||
return (String) System.getProperties().remove(name);
|
||||
}
|
||||
return (String) System.getProperties().setProperty(name, value);
|
||||
|
|
|
@ -87,10 +87,10 @@ public class DockerEngineException extends RuntimeException {
|
|||
Assert.notNull(uri, "URI must not be null");
|
||||
StringBuilder message = new StringBuilder(
|
||||
"Docker API call to '" + host + uri + "' failed with status code " + statusCode);
|
||||
if (!StringUtils.isEmpty(reasonPhrase)) {
|
||||
if (StringUtils.hasLength(reasonPhrase)) {
|
||||
message.append(" \"").append(reasonPhrase).append("\"");
|
||||
}
|
||||
if (responseMessage != null && !StringUtils.isEmpty(responseMessage.getMessage())) {
|
||||
if (responseMessage != null && StringUtils.hasLength(responseMessage.getMessage())) {
|
||||
message.append(" and message \"").append(responseMessage.getMessage()).append("\"");
|
||||
}
|
||||
if (errors != null && !errors.isEmpty()) {
|
||||
|
|
|
@ -258,7 +258,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
|
|||
}
|
||||
|
||||
private String getSubName(String name) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
return null;
|
||||
}
|
||||
int nested = name.lastIndexOf('$');
|
||||
|
|
|
@ -105,7 +105,7 @@ public class WebServerPortFileWriter implements ApplicationListener<WebServerIni
|
|||
*/
|
||||
protected File getPortFile(ApplicationContext applicationContext) {
|
||||
String namespace = getServerNamespace(applicationContext);
|
||||
if (StringUtils.isEmpty(namespace)) {
|
||||
if (!StringUtils.hasLength(namespace)) {
|
||||
return this.file;
|
||||
}
|
||||
String name = this.file.getName();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -71,7 +71,7 @@ final class CompressionCustomizer implements NettyServerCustomizer {
|
|||
.collect(Collectors.toList());
|
||||
return (request, response) -> {
|
||||
String contentType = response.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE);
|
||||
if (StringUtils.isEmpty(contentType)) {
|
||||
if (!StringUtils.hasLength(contentType)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class UndertowServletWebServer extends UndertowWebServer {
|
|||
@Override
|
||||
protected HttpHandler createHttpHandler() {
|
||||
HttpHandler handler = super.createHttpHandler();
|
||||
if (!StringUtils.isEmpty(this.contextPath)) {
|
||||
if (StringUtils.hasLength(this.contextPath)) {
|
||||
handler = Handlers.path().addPrefixPath(this.contextPath, handler);
|
||||
}
|
||||
return handler;
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class SslConfigurationValidator {
|
|||
}
|
||||
|
||||
public static void validateKeyAlias(KeyStore keyStore, String keyAlias) {
|
||||
if (!StringUtils.isEmpty(keyAlias)) {
|
||||
if (StringUtils.hasLength(keyAlias)) {
|
||||
try {
|
||||
Assert.state(keyStore.containsAlias(keyAlias),
|
||||
() -> String.format("Keystore does not contain specified alias '%s'", keyAlias));
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.springframework.boot.web.error.ErrorAttributeOptions.Include;
|
|||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.ObjectError;
|
||||
|
@ -199,10 +200,10 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
|
|||
*/
|
||||
protected String getMessage(WebRequest webRequest, Throwable error) {
|
||||
Object message = getAttribute(webRequest, RequestDispatcher.ERROR_MESSAGE);
|
||||
if (!StringUtils.isEmpty(message)) {
|
||||
if (!ObjectUtils.isEmpty(message)) {
|
||||
return message.toString();
|
||||
}
|
||||
if (error != null && !StringUtils.isEmpty(error.getMessage())) {
|
||||
if (error != null && StringUtils.hasLength(error.getMessage())) {
|
||||
return error.getMessage();
|
||||
}
|
||||
return "No message available";
|
||||
|
|
Loading…
Reference in New Issue