Skip to content

Commit 94f6151

Browse files
committed
fix-2148: fix some copilot comments
Signed-off-by: wind57 <eugen.rabii@gmail.com>
1 parent b71ab6b commit 94f6151

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ else if (source instanceof BootstrapPropertySource<?> bootstrapPropertySource) {
126126
if (sourceClass.isInstance(propertySource)) {
127127
sources.add(propertySource);
128128
}
129-
else if (propertySource instanceof MountConfigMapPropertySource mountConfigMapPropertySource) {
129+
else if (propertySource instanceof MountConfigMapPropertySource mountConfigMapPropertySource
130+
&& ConfigMapPropertySource.class.isAssignableFrom(sourceClass)) {
130131
// we know that the type is correct here
131132
managedSources.add((S) mountConfigMapPropertySource);
132133
}
133-
else if (propertySource instanceof MountSecretPropertySource mountSecretPropertySource) {
134+
else if (propertySource instanceof MountSecretPropertySource mountSecretPropertySource
135+
&& SecretsPropertySource.class.isAssignableFrom(sourceClass)) {
134136
// we know that the type is correct here
135137
managedSources.add((S) mountSecretPropertySource);
136138
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public Object getProperty(String name) {
157157
/**
158158
* <pre>
159159
* - in environment we have one MountSecretPropertySource
160-
* - we search for a type that extends SecretPropertySource (SecretsTypePropertySource)
160+
* - we search for a type that extends SecretsPropertySource (SecretsTypePropertySource)
161161
*
162162
* - we pick up MountSecretPropertySource
163163
* </pre>
@@ -178,7 +178,7 @@ void testSecretsPropertySource() {
178178
/**
179179
* <pre>
180180
* - in environment we have one MountSecretPropertySource
181-
* - we search for a type that does not extend SecretPropertySource (PlainPropertySource)
181+
* - we search for a type that does not extend SecretsPropertySource (PlainPropertySource)
182182
*
183183
* - we don't pick up MountSecretPropertySource
184184
* </pre>
@@ -198,7 +198,7 @@ void testSecretsPropertySourceNotTaken() {
198198
/**
199199
* <pre>
200200
* - in environment we have one MountConfigMapPropertySource
201-
* - we search for a type that extends SecretPropertySource (ConfigMapTypePropertySource)
201+
* - we search for a type that extends ConfigMapPropertySource (ConfigMapTypePropertySource)
202202
*
203203
* - we pick up MountConfigMapPropertySource
204204
* </pre>
@@ -229,7 +229,7 @@ void testConfigMapPropertySource() {
229229
void testConfigMapPropertySourceNotTaken() {
230230
MockEnvironment environment = new MockEnvironment();
231231
MutablePropertySources propertySources = environment.getPropertySources();
232-
propertySources.addFirst(new MountSecretPropertySource(new SourceData("secret", Map.of("a", "b"))));
232+
propertySources.addFirst(new MountConfigMapPropertySource("secret", Map.of("a", "b")));
233233

234234
List<? extends PropertySource> result = ConfigReloadUtil.findPropertySources(PlainPropertySource.class,
235235
environment);

0 commit comments

Comments
 (0)