Merge branch 'pr/1953'

This commit is contained in:
Ryan Baxter
2023-02-10 09:10:56 -05:00
9 changed files with 23 additions and 17 deletions

View File

@@ -31,6 +31,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.config.environment.EnvironmentMediaType;
import org.springframework.cloud.configuration.TlsProperties;
import org.springframework.core.env.Environment;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
@@ -333,7 +334,7 @@ public class ConfigClientProperties {
URL url = new URL(uri);
String userInfo = url.getUserInfo();
// no credentials in url, return explicit credentials
if (StringUtils.isEmpty(userInfo) || ":".equals(userInfo)) {
if (ObjectUtils.isEmpty(userInfo) || ":".equals(userInfo)) {
return result;
}
String bare = UriComponentsBuilder.fromHttpUrl(uri).userInfo(null).build().toUriString();

View File

@@ -28,7 +28,7 @@ import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.cloud.config.server.encryption.CipherEnvironmentEncryptor;
import org.springframework.cloud.config.server.encryption.EnvironmentEncryptor;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.vault.core.VaultKeyValueOperations;
import org.springframework.vault.support.VaultResponse;
@@ -80,7 +80,7 @@ public class VaultEnvironmentEncryptor implements EnvironmentEncryptor {
throw new RuntimeException("Wrong format");
}
if (StringUtils.isEmpty(parts[0]) || StringUtils.isEmpty(parts[1])) {
if (ObjectUtils.isEmpty(parts[0]) || ObjectUtils.isEmpty(parts[1])) {
throw new RuntimeException("Wrong format");
}

View File

@@ -31,6 +31,7 @@ import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.cloud.config.server.config.ConfigServerProperties;
import org.springframework.core.Ordered;
import org.springframework.core.io.InputStreamResource;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
@@ -118,11 +119,11 @@ public class AwsS3EnvironmentRepository implements EnvironmentRepository, Ordere
private String buildObjectKeyPrefix(String application, String profile, String label) {
StringBuilder objectKeyPrefix = new StringBuilder();
if (!StringUtils.isEmpty(label)) {
if (!ObjectUtils.isEmpty(label)) {
objectKeyPrefix.append(label).append(PATH_SEPARATOR);
}
objectKeyPrefix.append(application);
if (!StringUtils.isEmpty(profile)) {
if (!ObjectUtils.isEmpty(profile)) {
objectKeyPrefix.append("-").append(profile);
}
return objectKeyPrefix.toString();

View File

@@ -34,6 +34,7 @@ import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.cloud.config.server.config.ConfigServerProperties;
import org.springframework.core.Ordered;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import static org.springframework.cloud.config.server.environment.AwsSecretsManagerEnvironmentProperties.DEFAULT_PATH_SEPARATOR;
@@ -71,11 +72,11 @@ public class AwsSecretsManagerEnvironmentRepository implements EnvironmentReposi
final String defaultApplication = configServerProperties.getDefaultApplicationName();
final String defaultProfile = configServerProperties.getDefaultProfile();
if (StringUtils.isEmpty(application)) {
if (ObjectUtils.isEmpty(application)) {
application = defaultApplication;
}
if (StringUtils.isEmpty(profileList)) {
if (ObjectUtils.isEmpty(profileList)) {
profileList = defaultProfile;
}

View File

@@ -26,6 +26,7 @@ import org.springframework.credhub.core.CredHubOperations;
import org.springframework.credhub.support.CredentialDetails;
import org.springframework.credhub.support.SimpleCredentialName;
import org.springframework.credhub.support.json.JsonCredential;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import static java.util.stream.Collectors.toMap;
@@ -52,10 +53,10 @@ public class CredhubEnvironmentRepository implements EnvironmentRepository, Orde
@Override
public Environment findOne(String application, String profilesList, String label) {
if (StringUtils.isEmpty(profilesList)) {
if (ObjectUtils.isEmpty(profilesList)) {
profilesList = DEFAULT_PROFILE;
}
if (StringUtils.isEmpty(label)) {
if (ObjectUtils.isEmpty(label)) {
label = DEFAULT_LABEL;
}

View File

@@ -36,7 +36,7 @@ import org.eclipse.jgit.transport.http.HttpConnection;
import org.eclipse.jgit.transport.http.apache.HttpClientConnection;
import org.springframework.cloud.config.server.support.HttpClient4Support;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import static java.util.stream.Collectors.toMap;
@@ -152,14 +152,14 @@ public class HttpClientConfigurableHttpConnectionFactory implements Configurable
List<String> values = new LinkedList<>();
for (String token : tokens) {
String[] valueTokens = spec.split(token);
if (!StringUtils.isEmpty(valueTokens[0])) {
if (!ObjectUtils.isEmpty(valueTokens[0])) {
values.add(valueTokens[0]);
}
if (valueTokens.length > 1) {
spec = valueTokens[1];
}
}
if (tokens.length == 1 && !StringUtils.isEmpty(spec)) {
if (tokens.length == 1 && !ObjectUtils.isEmpty(spec)) {
values.add(spec);
}
return values;

View File

@@ -61,6 +61,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.UrlResource;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import static java.lang.String.format;
@@ -366,14 +367,14 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
// Check if git points to valid repository and default label is not empty or
// null.
if (null != git && git.getRepository() != null && !StringUtils.isEmpty(getDefaultLabel())) {
if (null != git && git.getRepository() != null && !ObjectUtils.isEmpty(getDefaultLabel())) {
// Checkout the default branch set for repo in git. This may not always be
// master. It depends on the
// admin and organization settings.
String defaultBranchInGit = git.getRepository().getBranch();
// If default branch is not empty and NOT equal to defaultLabel, then
// checkout the branch/tag/commit-id.
if (!StringUtils.isEmpty(defaultBranchInGit)
if (!ObjectUtils.isEmpty(defaultBranchInGit)
&& !getDefaultLabel().equalsIgnoreCase(defaultBranchInGit)) {
checkoutDefaultBranchWithRetry(git);
}

View File

@@ -20,7 +20,7 @@ import org.springframework.cloud.config.server.environment.VaultEnvironmentPrope
import org.springframework.cloud.config.server.environment.VaultEnvironmentProperties.AuthenticationMethod;
import org.springframework.cloud.config.server.environment.vault.SpringVaultClientAuthenticationProvider;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.vault.authentication.ClientAuthentication;
import org.springframework.vault.authentication.PcfAuthentication;
import org.springframework.vault.authentication.PcfAuthenticationOptions;
@@ -67,7 +67,7 @@ public class PcfClientAuthenticationProvider extends SpringVaultClientAuthentica
String value = System.getenv(name);
if (StringUtils.isEmpty(value)) {
if (ObjectUtils.isEmpty(value)) {
throw new IllegalStateException(String.format("Environment variable %s not set", name));
}

View File

@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
@@ -44,7 +45,7 @@ public abstract class PathUtils {
* @return {@code true} if the path is invalid, {@code false} otherwise
*/
public static boolean isInvalidEncodedLocation(String location) {
if (StringUtils.isEmpty(location)) {
if (ObjectUtils.isEmpty(location)) {
return false;
}
if (location.contains("%")) {