Commit 2d8528d5 authored by Andy Wilkinson's avatar Andy Wilkinson

Adapt to deprecation of StringUtils.isEmpty(Object)

See gh-23774
parent 3bfe1b00
...@@ -296,11 +296,11 @@ public final class ConditionMessage { ...@@ -296,11 +296,11 @@ public final class ConditionMessage {
* @return a built {@link ConditionMessage} * @return a built {@link ConditionMessage}
*/ */
public ConditionMessage because(String reason) { public ConditionMessage because(String reason) {
if (StringUtils.isEmpty(reason)) { if (StringUtils.hasLength(reason)) {
return new ConditionMessage(ConditionMessage.this, this.condition); return new ConditionMessage(ConditionMessage.this,
StringUtils.hasLength(this.condition) ? this.condition + " " + reason : reason);
} }
return new ConditionMessage(ConditionMessage.this, return new ConditionMessage(ConditionMessage.this, this.condition);
StringUtils.isEmpty(this.condition) ? reason : this.condition + " " + reason);
} }
} }
......
...@@ -140,7 +140,7 @@ public class EntityScanPackages { ...@@ -140,7 +140,7 @@ public class EntityScanPackages {
} }
if (packagesToScan.isEmpty()) { if (packagesToScan.isEmpty()) {
String packageName = ClassUtils.getPackageName(metadata.getClassName()); 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 Collections.singleton(packageName);
} }
return packagesToScan; return packagesToScan;
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -277,10 +277,10 @@ public final class TestPropertyValues { ...@@ -277,10 +277,10 @@ public final class TestPropertyValues {
} }
private static Pair of(String name, String value) { private static Pair of(String name, String value) {
if (StringUtils.isEmpty(name) && StringUtils.isEmpty(value)) { if (StringUtils.hasLength(name) || StringUtils.hasLength(value)) {
return null; return new Pair(name, value);
} }
return new Pair(name, value); return null;
} }
} }
...@@ -309,7 +309,7 @@ public final class TestPropertyValues { ...@@ -309,7 +309,7 @@ public final class TestPropertyValues {
private String setOrClear(String name, String value) { private String setOrClear(String name, String value) {
Assert.notNull(name, "Name must not be null"); 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().remove(name);
} }
return (String) System.getProperties().setProperty(name, value); return (String) System.getProperties().setProperty(name, value);
......
...@@ -87,10 +87,10 @@ public class DockerEngineException extends RuntimeException { ...@@ -87,10 +87,10 @@ public class DockerEngineException extends RuntimeException {
Assert.notNull(uri, "URI must not be null"); Assert.notNull(uri, "URI must not be null");
StringBuilder message = new StringBuilder( StringBuilder message = new StringBuilder(
"Docker API call to '" + host + uri + "' failed with status code " + statusCode); "Docker API call to '" + host + uri + "' failed with status code " + statusCode);
if (!StringUtils.isEmpty(reasonPhrase)) { if (StringUtils.hasLength(reasonPhrase)) {
message.append(" \"").append(reasonPhrase).append("\""); 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("\""); message.append(" and message \"").append(responseMessage.getMessage()).append("\"");
} }
if (errors != null && !errors.isEmpty()) { if (errors != null && !errors.isEmpty()) {
......
...@@ -258,7 +258,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem { ...@@ -258,7 +258,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
} }
private String getSubName(String name) { private String getSubName(String name) {
if (StringUtils.isEmpty(name)) { if (!StringUtils.hasLength(name)) {
return null; return null;
} }
int nested = name.lastIndexOf('$'); int nested = name.lastIndexOf('$');
......
...@@ -105,7 +105,7 @@ public class WebServerPortFileWriter implements ApplicationListener<WebServerIni ...@@ -105,7 +105,7 @@ public class WebServerPortFileWriter implements ApplicationListener<WebServerIni
*/ */
protected File getPortFile(ApplicationContext applicationContext) { protected File getPortFile(ApplicationContext applicationContext) {
String namespace = getServerNamespace(applicationContext); String namespace = getServerNamespace(applicationContext);
if (StringUtils.isEmpty(namespace)) { if (!StringUtils.hasLength(namespace)) {
return this.file; return this.file;
} }
String name = this.file.getName(); String name = this.file.getName();
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -71,7 +71,7 @@ final class CompressionCustomizer implements NettyServerCustomizer { ...@@ -71,7 +71,7 @@ final class CompressionCustomizer implements NettyServerCustomizer {
.collect(Collectors.toList()); .collect(Collectors.toList());
return (request, response) -> { return (request, response) -> {
String contentType = response.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE); String contentType = response.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE);
if (StringUtils.isEmpty(contentType)) { if (!StringUtils.hasLength(contentType)) {
return false; return false;
} }
try { try {
......
...@@ -123,7 +123,7 @@ public class UndertowServletWebServer extends UndertowWebServer { ...@@ -123,7 +123,7 @@ public class UndertowServletWebServer extends UndertowWebServer {
@Override @Override
protected HttpHandler createHttpHandler() { protected HttpHandler createHttpHandler() {
HttpHandler handler = super.createHttpHandler(); HttpHandler handler = super.createHttpHandler();
if (!StringUtils.isEmpty(this.contextPath)) { if (StringUtils.hasLength(this.contextPath)) {
handler = Handlers.path().addPrefixPath(this.contextPath, handler); handler = Handlers.path().addPrefixPath(this.contextPath, handler);
} }
return handler; return handler;
......
...@@ -34,7 +34,7 @@ public final class SslConfigurationValidator { ...@@ -34,7 +34,7 @@ public final class SslConfigurationValidator {
} }
public static void validateKeyAlias(KeyStore keyStore, String keyAlias) { public static void validateKeyAlias(KeyStore keyStore, String keyAlias) {
if (!StringUtils.isEmpty(keyAlias)) { if (StringUtils.hasLength(keyAlias)) {
try { try {
Assert.state(keyStore.containsAlias(keyAlias), Assert.state(keyStore.containsAlias(keyAlias),
() -> String.format("Keystore does not contain specified alias '%s'", keyAlias)); () -> String.format("Keystore does not contain specified alias '%s'", keyAlias));
......
...@@ -32,6 +32,7 @@ import org.springframework.boot.web.error.ErrorAttributeOptions.Include; ...@@ -32,6 +32,7 @@ import org.springframework.boot.web.error.ErrorAttributeOptions.Include;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError; import org.springframework.validation.ObjectError;
...@@ -199,10 +200,10 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException ...@@ -199,10 +200,10 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
*/ */
protected String getMessage(WebRequest webRequest, Throwable error) { protected String getMessage(WebRequest webRequest, Throwable error) {
Object message = getAttribute(webRequest, RequestDispatcher.ERROR_MESSAGE); Object message = getAttribute(webRequest, RequestDispatcher.ERROR_MESSAGE);
if (!StringUtils.isEmpty(message)) { if (!ObjectUtils.isEmpty(message)) {
return message.toString(); return message.toString();
} }
if (error != null && !StringUtils.isEmpty(error.getMessage())) { if (error != null && StringUtils.hasLength(error.getMessage())) {
return error.getMessage(); return error.getMessage();
} }
return "No message available"; return "No message available";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment