Skip to content

Commit 76abe25

Browse files
committed
checkstyle
Signed-off-by: wind57 <[email protected]>
1 parent e5cd2fb commit 76abe25

File tree

7 files changed

+54
-54
lines changed

7 files changed

+54
-54
lines changed

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public final class ConfigUtils {
5858

5959
// sourceName (configmap or secret name) ends with : "-dev.yaml" or the like.
6060
private static final BiPredicate<String, String> ENDS_WITH_PROFILE_AND_EXTENSION = (sourceName,
61-
activeProfile) -> sourceName.endsWith("-" + activeProfile + ".yml")
62-
|| sourceName.endsWith("-" + activeProfile + ".yaml")
63-
|| sourceName.endsWith("-" + activeProfile + ".properties");
61+
activeProfile) -> sourceName.endsWith("-" + activeProfile + ".yml")
62+
|| sourceName.endsWith("-" + activeProfile + ".yaml")
63+
|| sourceName.endsWith("-" + activeProfile + ".properties");
6464

6565
private static final ApplicationListener<?> NO_OP = (e) -> {
6666
};
@@ -71,7 +71,7 @@ private ConfigUtils() {
7171
public static String getApplicationName(Environment env, String configName, String configurationTarget) {
7272
if (!StringUtils.hasLength(configName)) {
7373
LOG.debug(configurationTarget + " name has not been set, taking it from property/env "
74-
+ SPRING_APPLICATION_NAME + " (default=" + FALLBACK_APPLICATION_NAME + ")");
74+
+ SPRING_APPLICATION_NAME + " (default=" + FALLBACK_APPLICATION_NAME + ")");
7575
configName = env.getProperty(SPRING_APPLICATION_NAME, FALLBACK_APPLICATION_NAME);
7676
}
7777

@@ -91,7 +91,7 @@ public static String getApplicationName(Environment env, String configName, Stri
9191
* @return prefix to use in normalized sources
9292
*/
9393
public static Prefix findPrefix(String explicitPrefix, Boolean useNameAsPrefix, boolean defaultUseNameAsPrefix,
94-
String normalizedName) {
94+
String normalizedName) {
9595
// if explicitPrefix is set, it takes priority over useNameAsPrefix
9696
// (either the one from 'spring.cloud.kubernetes.config|secrets' or
9797
// 'spring.cloud.kubernetes.config|secrets.sources')
@@ -141,7 +141,7 @@ public static Prefix findPrefix(String explicitPrefix, Boolean useNameAsPrefix,
141141
* @return useProfileNameAsPrefix to be used in normalized sources
142142
*/
143143
public static boolean includeProfileSpecificSources(boolean defaultIncludeProfileSpecificSources,
144-
Boolean includeProfileSpecificSources) {
144+
Boolean includeProfileSpecificSources) {
145145
if (includeProfileSpecificSources != null) {
146146
return includeProfileSpecificSources;
147147
}
@@ -171,7 +171,7 @@ public static String sourceName(String target, String applicationName, String na
171171
}
172172

173173
public static MultipleSourcesContainer processNamedData(List<StrippedSourceContainer> strippedSources,
174-
Environment environment, LinkedHashSet<String> sourceNames, String namespace, boolean decode) {
174+
Environment environment, LinkedHashSet<String> sourceNames, String namespace, boolean decode) {
175175
return processNamedData(strippedSources, environment, sourceNames, namespace, decode, true);
176176
}
177177

@@ -181,8 +181,8 @@ public static MultipleSourcesContainer processNamedData(List<StrippedSourceConta
181181
* defined order).
182182
*/
183183
public static MultipleSourcesContainer processNamedData(List<StrippedSourceContainer> strippedSources,
184-
Environment environment, LinkedHashSet<String> sourceNames, String namespace, boolean decode,
185-
boolean includeDefaultProfileData) {
184+
Environment environment, LinkedHashSet<String> sourceNames, String namespace, boolean decode,
185+
boolean includeDefaultProfileData) {
186186

187187
Map<String, StrippedSourceContainer> hashByName = strippedSources.stream()
188188
.collect(Collectors.toMap(StrippedSourceContainer::name, Function.identity()));
@@ -212,7 +212,7 @@ public static MultipleSourcesContainer processNamedData(List<StrippedSourceConta
212212
*/
213213
if (processSource(includeDefaultProfileData, environment, sourceName, rawData)) {
214214
Map<String, Object> processedData = SourceDataEntriesProcessor.processAllEntries(
215-
rawData == null ? Map.of() : rawData, environment, includeDefaultProfileData);
215+
rawData == null ? Map.of() : rawData, environment, includeDefaultProfileData);
216216
data.put(sourceName, processedData);
217217
}
218218
}
@@ -225,7 +225,7 @@ public static MultipleSourcesContainer processNamedData(List<StrippedSourceConta
225225
}
226226

227227
static boolean processSource(boolean includeDefaultProfileData, Environment environment, String sourceName,
228-
Map<String, String> sourceRawData) {
228+
Map<String, String> sourceRawData) {
229229
List<String> activeProfiles = Arrays.stream(environment.getActiveProfiles()).toList();
230230

231231
boolean emptyActiveProfiles = activeProfiles.isEmpty();
@@ -236,7 +236,7 @@ static boolean processSource(boolean includeDefaultProfileData, Environment envi
236236
boolean defaultProfilePresent = activeProfiles.contains("default");
237237

238238
return includeDefaultProfileData || emptyActiveProfiles || profileBasedSourceName || defaultProfilePresent
239-
|| rawDataContainsProfileBasedSource(activeProfiles, sourceRawData).getAsBoolean();
239+
|| rawDataContainsProfileBasedSource(activeProfiles, sourceRawData).getAsBoolean();
240240
}
241241

242242
/*
@@ -248,7 +248,7 @@ static boolean processSource(boolean includeDefaultProfileData, Environment envi
248248
* yaml/yml/properties. For example: 'account-k8s.yaml' or the like.
249249
*/
250250
static BooleanSupplier rawDataContainsProfileBasedSource(List<String> activeProfiles,
251-
Map<String, String> sourceRawData) {
251+
Map<String, String> sourceRawData) {
252252
return () -> Optional.ofNullable(sourceRawData)
253253
.orElse(Map.of())
254254
.keySet()
@@ -269,8 +269,8 @@ static String sourceDataName(String target, Set<String> sourceNames, String name
269269
* these names to find any profile-based sources.
270270
*/
271271
public static MultipleSourcesContainer processLabeledData(List<StrippedSourceContainer> containers,
272-
Environment environment, Map<String, String> labels, String namespace, Set<String> profiles,
273-
boolean decode) {
272+
Environment environment, Map<String, String> labels, String namespace, Set<String> profiles,
273+
boolean decode) {
274274

275275
// find sources by provided labels
276276
List<StrippedSourceContainer> byLabels = containers.stream().filter(one -> {
@@ -327,7 +327,7 @@ private static Map<String, String> decodeData(Map<String, String> data) {
327327
}
328328

329329
public static <T> void registerSingle(ConfigurableBootstrapContext bootstrapContext, Class<T> cls, T instance,
330-
String name, ApplicationListener<?> listener) {
330+
String name, ApplicationListener<?> listener) {
331331
bootstrapContext.registerIfAbsent(cls, BootstrapRegistry.InstanceSupplier.of(instance));
332332
bootstrapContext.addCloseListener(event -> {
333333

@@ -341,7 +341,7 @@ public static <T> void registerSingle(ConfigurableBootstrapContext bootstrapCont
341341
}
342342

343343
public static <T> void registerSingle(ConfigurableBootstrapContext bootstrapContext, Class<T> cls, T instance,
344-
String name) {
344+
String name) {
345345
registerSingle(bootstrapContext, cls, instance, name, NO_OP);
346346
}
347347

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class LabeledSourceData {
4646
private static final Log LOG = LogFactory.getLog(LabeledSourceData.class);
4747

4848
public final SourceData compute(Map<String, String> labels, Prefix prefix, String target, boolean profileSources,
49-
boolean failFast, String namespace, String[] activeProfiles) {
49+
boolean failFast, String namespace, String[] activeProfiles) {
5050

5151
MultipleSourcesContainer data = MultipleSourcesContainer.empty();
5252
String sourceDataName;
@@ -70,7 +70,7 @@ public final SourceData compute(Map<String, String> labels, Prefix prefix, Strin
7070

7171
if (prefix.getName().equals(Prefix.KNOWN.getName())) {
7272
return new SourceData(sourceDataName,
73-
prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get()));
73+
prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get()));
7474
}
7575

7676
if (prefix.getName().equals(Prefix.DELAYED.getName())) {
@@ -83,7 +83,7 @@ public final SourceData compute(Map<String, String> labels, Prefix prefix, Strin
8383
LOG.warn("Failure in reading labeled sources");
8484
onException(failFast, e);
8585
return new SourceData(sourceDataName(target, data.data().keySet(), namespace),
86-
Map.of(ERROR_PROPERTY, "true"));
86+
Map.of(ERROR_PROPERTY, "true"));
8787
}
8888

8989
}
@@ -97,7 +97,7 @@ private SourceData emptySourceData(Map<String, String> labels, String target, St
9797
.stream()
9898
.sorted()
9999
.collect(Collectors.collectingAndThen(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR),
100-
sortedLabels -> sourceName(target, sortedLabels, namespace)));
100+
sortedLabels -> sourceName(target, sortedLabels, namespace)));
101101

102102
return SourceData.emptyRecord(sourceName);
103103
}

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public abstract class NamedSourceData {
4545
private static final Log LOG = LogFactory.getLog(NamedSourceData.class);
4646

4747
public final SourceData compute(String sourceName, Prefix prefix, String target, boolean profileSources,
48-
boolean failFast, String namespace, String[] activeProfiles) {
48+
boolean failFast, String namespace, String[] activeProfiles) {
4949

5050
// first comes a non-profile-based source
5151
LinkedHashSet<String> sourceNamesToSearchFor = new LinkedHashSet<>();
@@ -80,7 +80,7 @@ public final SourceData compute(String sourceName, Prefix prefix, String target,
8080

8181
if (prefix.getName().equals(Prefix.KNOWN.getName())) {
8282
return new SourceData(sourceDataName,
83-
prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get()));
83+
prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get()));
8484
}
8585

8686
if (prefix.getName().equals(Prefix.DELAYED.getName())) {
@@ -99,7 +99,7 @@ public final SourceData compute(String sourceName, Prefix prefix, String target,
9999
.sorted()
100100
.collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR));
101101
return new SourceData(generateSourceName(target, names, namespace, activeProfiles),
102-
Map.of(ERROR_PROPERTY, "true"));
102+
Map.of(ERROR_PROPERTY, "true"));
103103
}
104104

105105
}

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static Map<String, Object> defaultFlattenedSourceData(LinkedHashMap<String, Map<
4242
* Flattens the data from rawData by adding a prefix for each key.
4343
*/
4444
static Map<String, Object> prefixFlattenedSourceData(LinkedHashMap<String, Map<String, Object>> sourceData,
45-
String prefix) {
45+
String prefix) {
4646
Map<String, Object> flattenedData = new HashMap<>();
4747
sourceData.values().forEach(data -> data.forEach((key, value) -> flattenedData.put(prefix + "." + key, value)));
4848
return flattenedData;

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsProcessSourceTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void testProcessNamedDataOne() {
7878
boolean includeDefaultProfileData = true;
7979

8080
MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames,
81-
namespace, decode, includeDefaultProfileData);
81+
namespace, decode, includeDefaultProfileData);
8282
Assertions.assertThat(result).isNotNull();
8383
Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("configmap-a");
8484

@@ -159,7 +159,7 @@ void testProcessNamedDataTwo(CapturedOutput output) {
159159
boolean includeDefaultProfileData = false;
160160

161161
MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames,
162-
namespace, decode, includeDefaultProfileData);
162+
namespace, decode, includeDefaultProfileData);
163163
Assertions.assertThat(result).isNotNull();
164164
Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account");
165165

@@ -254,7 +254,7 @@ void testProcessNamedDataThree(CapturedOutput output) {
254254
boolean includeDefaultProfileData = false;
255255

256256
MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames,
257-
namespace, decode, includeDefaultProfileData);
257+
namespace, decode, includeDefaultProfileData);
258258
Assertions.assertThat(result).isNotNull();
259259
Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account-default");
260260

@@ -368,7 +368,7 @@ void testProcessNamedDataFive(CapturedOutput output) {
368368
boolean includeDefaultProfileData = false;
369369

370370
MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames,
371-
namespace, decode, includeDefaultProfileData);
371+
namespace, decode, includeDefaultProfileData);
372372
Assertions.assertThat(result).isNotNull();
373373
Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account");
374374

@@ -456,7 +456,7 @@ void testProcessNamedDataSix(CapturedOutput output) {
456456
boolean includeDefaultProfileData = false;
457457

458458
MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames,
459-
namespace, decode, includeDefaultProfileData);
459+
namespace, decode, includeDefaultProfileData);
460460
Assertions.assertThat(result).isNotNull();
461461
Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account-k8s");
462462

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ void testUseIncludeProfileSpecificSourcesSourcesOverridesDefault() {
154154
void testMerge() {
155155

156156
StrippedSourceContainer configMapOne = new StrippedSourceContainer(Map.of(), "configmap-one",
157-
Map.of(Constants.APPLICATION_YAML, "propA: A\npropB: B"));
157+
Map.of(Constants.APPLICATION_YAML, "propA: A\npropB: B"));
158158

159159
StrippedSourceContainer configMapOneK8s = new StrippedSourceContainer(Map.of(), "configmap-one-kubernetes",
160-
Map.of(Constants.APPLICATION_YAML, "propA: AA\npropC: C"));
160+
Map.of(Constants.APPLICATION_YAML, "propA: AA\npropC: C"));
161161

162162
LinkedHashSet<String> sourceNames = Stream.of("configmap-one", "configmap-one-kubernetes")
163163
.collect(Collectors.toCollection(LinkedHashSet::new));
164164

165165
MultipleSourcesContainer result = ConfigUtils.processNamedData(List.of(configMapOne, configMapOneK8s),
166-
new MockEnvironment(), sourceNames, "default", false);
166+
new MockEnvironment(), sourceNames, "default", false);
167167

168168
Assertions.assertThat(result.data().size()).isEqualTo(2);
169169
Map<String, Object> one = result.data().get("configmap-one");
@@ -206,13 +206,13 @@ void testKeysWithPrefixNonEmptyPrefix() {
206206
void testIssue1757() {
207207

208208
StrippedSourceContainer containerA = new StrippedSourceContainer(Map.of("load", "true"), "client-1",
209-
Map.of("client-id", "clientA", "client-secret", "a"));
209+
Map.of("client-id", "clientA", "client-secret", "a"));
210210

211211
StrippedSourceContainer containerB = new StrippedSourceContainer(Map.of("load", "true"), "client-2",
212-
Map.of("client-id", "clientB", "client-secret", "b"));
212+
Map.of("client-id", "clientB", "client-secret", "b"));
213213

214214
MultipleSourcesContainer container = ConfigUtils.processLabeledData(List.of(containerA, containerB),
215-
new MockEnvironment(), Map.of("load", "true"), "default", Set.of(), false);
215+
new MockEnvironment(), Map.of("load", "true"), "default", Set.of(), false);
216216

217217
assertThat(container.data().keySet()).containsExactlyInAnyOrder("client-1", "client-2");
218218

0 commit comments

Comments
 (0)