Updates for checkstyle

This commit is contained in:
spencergibb
2024-11-07 11:02:32 -05:00
parent 6f496553f0
commit 962ef9f540
15 changed files with 48 additions and 28 deletions

View File

@@ -31,6 +31,7 @@ import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@@ -295,8 +296,9 @@ class FileWalker extends SimpleFileVisitor<Path> {
Path foundFile;
FileWalker(StubConfiguration stubConfiguration) {
this.latestSnapshotVersion = LATEST.stream().anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase()));
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase());
this.latestSnapshotVersion = LATEST.stream()
.anyMatch(s -> s.equals(stubConfiguration.version.toLowerCase(Locale.ROOT)));
this.latestReleaseVersion = RELEASE.equals(stubConfiguration.version.toLowerCase(Locale.ROOT));
this.matcherWithDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "."));
this.matcherWithoutDot = FileSystems.getDefault().getPathMatcher("glob:" + matcherGlob(stubConfiguration, "/"));
}
@@ -368,12 +370,12 @@ class FileWalker extends SimpleFileVisitor<Path> {
private File folderWithPredefinedName(File[] files) {
if (this.latestSnapshotVersion) {
return Arrays.stream(files)
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase())))
.filter(file -> LATEST.stream().anyMatch(s -> s.equals(file.getName().toLowerCase(Locale.ROOT))))
.findFirst()
.orElse(null);
}
return Arrays.stream(files)
.filter(file -> RELEASE.equals(file.getName().toLowerCase()))
.filter(file -> RELEASE.equals(file.getName().toLowerCase(Locale.ROOT)))
.findFirst()
.orElse(null);
}

View File

@@ -16,6 +16,8 @@
package org.springframework.cloud.contract.stubrunner;
import java.util.Locale;
import org.springframework.util.StringUtils;
/**
@@ -128,7 +130,7 @@ public class StubConfiguration {
* @return {@code true} for a snapshot or a LATEST (+) version.
*/
public boolean isVersionChanging() {
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase().contains("snapshot");
return DEFAULT_VERSION.equals(this.version) || this.version.toLowerCase(Locale.ROOT).contains("snapshot");
}
public String getGroupId() {

View File

@@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -213,7 +214,7 @@ public class StubRunnerOptions {
Set<String> propertyNames = properties.stringPropertyNames();
propertyNames.stream()
// stubrunner.properties.foo.bar=baz
.filter(s -> s.toLowerCase().startsWith("stubrunner.properties"))
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("stubrunner.properties"))
// foo.bar=baz
.forEach(s -> map.put(s.substring("stubrunner.properties".length() + 1), System.getProperty(s)));
return map;

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.contract.stubrunner;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.commons.logging.Log;
@@ -81,7 +82,7 @@ public final class StubRunnerPropertyUtils {
}
private static String appendPrefixIfNecessary(String prop) {
if (prop.toLowerCase().startsWith("stubrunner")) {
if (prop.toLowerCase(Locale.ROOT).startsWith("stubrunner")) {
return prop;
}
return STUBRUNNER_PROPERTIES + "." + prop;
@@ -95,7 +96,7 @@ public final class StubRunnerPropertyUtils {
}
return systemProp;
}
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase();
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_").replaceAll("-", "_").toUpperCase(Locale.ROOT);
String envVar = FETCHER.envVar(convertedEnvProp);
if (log.isTraceEnabled()) {
log.trace("Environment variable [" + convertedEnvProp + "] has value [" + envVar + "]");