Use CollectionUtils.isEmpty() and StringUtils.hasLength()
See gh-40645
This commit is contained in:
committed by
Moritz Halbritter
parent
a67c8e4bbd
commit
0e450d602d
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.buildpack.platform.build;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Exception thrown to indicate a Builder error.
|
||||
*
|
||||
@@ -52,7 +54,7 @@ public class BuilderException extends RuntimeException {
|
||||
|
||||
private static String buildMessage(String operation, int statusCode) {
|
||||
StringBuilder message = new StringBuilder("Builder");
|
||||
if (operation != null && !operation.isEmpty()) {
|
||||
if (StringUtils.hasLength(operation)) {
|
||||
message.append(" lifecycle '").append(operation).append("'");
|
||||
}
|
||||
message.append(" failed with status code ").append(statusCode);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
|
||||
import org.springframework.boot.buildpack.platform.docker.type.Layer;
|
||||
import org.springframework.boot.buildpack.platform.io.Content;
|
||||
import org.springframework.boot.buildpack.platform.io.Owner;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* A short-lived builder that is created for each {@link Lifecycle} run.
|
||||
@@ -66,7 +67,7 @@ class EphemeralBuilder {
|
||||
update.withUpdatedConfig(this.builderMetadata::attachTo);
|
||||
update.withUpdatedConfig((config) -> config.withLabel(BUILDER_FOR_LABEL_NAME, targetImage.toString()));
|
||||
update.withTag(name);
|
||||
if (env != null && !env.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(env)) {
|
||||
update.withNewLayer(getEnvLayer(env));
|
||||
}
|
||||
if (buildpacks != null) {
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.boot.buildpack.platform.docker;
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Utility to render a simple progress bar based on consumed {@link TotalProgressEvent}
|
||||
* objects.
|
||||
@@ -63,7 +65,7 @@ public class TotalProgressBar implements Consumer<TotalProgressEvent> {
|
||||
public TotalProgressBar(String prefix, char progressChar, boolean bookend, PrintStream out) {
|
||||
this.progressChar = progressChar;
|
||||
this.bookend = bookend;
|
||||
if (prefix != null && !prefix.isEmpty()) {
|
||||
if (StringUtils.hasLength(prefix)) {
|
||||
out.print(prefix);
|
||||
out.print(" ");
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import org.springframework.boot.buildpack.platform.json.SharedObjectMapper;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class ContainerConfig {
|
||||
}
|
||||
ArrayNode bindsNode = hostConfigNode.putArray("Binds");
|
||||
bindings.forEach((binding) -> bindsNode.add(binding.toString()));
|
||||
if (securityOptions != null && !securityOptions.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(securityOptions)) {
|
||||
ArrayNode securityOptsNode = hostConfigNode.putArray("SecurityOpt");
|
||||
securityOptions.forEach(securityOptsNode::add);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user