Skip to content

Commit acbaa77

Browse files
committed
java 16 compatibility: reducing inaccessibility impact
1 parent 9e1e8e3 commit acbaa77

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromConfigMapProcessor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public class KubernetesFromConfigMapProcessor
5454
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
5555

5656
for (Field field : bean.getClass().getDeclaredFields()) {
57+
// skip if the field if the FromYaml annotation is missing
58+
FromConfigMap fromConfigMapAnnotation = field.getAnnotation(FromConfigMap.class);
59+
if (fromConfigMapAnnotation == null) {
60+
continue;
61+
}
62+
// injecting
5763
ReflectionUtils.makeAccessible(field);
5864
try {
5965
if (field.get(bean) != null) {
@@ -64,11 +70,6 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
6470
continue;
6571
}
6672

67-
FromConfigMap fromConfigMapAnnotation = field.getAnnotation(FromConfigMap.class);
68-
if (fromConfigMapAnnotation == null) {
69-
continue; // skip if the field doesn't have the annotation
70-
}
71-
7273
if (!Map.class.isAssignableFrom(field.getType())) {
7374
log.warn(
7475
"Failed inject resource for @FromConfigMap annotated field {}, the declaring type should be Map<String, String>",

spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromYamlProcessor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
6060
}
6161

6262
for (Field field : bean.getClass().getDeclaredFields()) {
63+
// skip if the field if the FromYaml annotation is missing
64+
fromYamlAnnotation = field.getAnnotation(FromYaml.class);
65+
if (fromYamlAnnotation == null) {
66+
continue; // skip if the field doesn't have the annotation
67+
}
68+
// injecting
6369
ReflectionUtils.makeAccessible(field);
6470
try {
6571
if (field.get(bean) != null) {
@@ -70,11 +76,6 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
7076
continue;
7177
}
7278

73-
fromYamlAnnotation = field.getAnnotation(FromYaml.class);
74-
if (fromYamlAnnotation == null) {
75-
continue; // skip if the field doesn't have the annotation
76-
}
77-
7879
Object loadedObj = loadFromYaml(fromYamlAnnotation.filePath());
7980
ReflectionUtils.setField(field, bean, loadedObj);
8081
}

0 commit comments

Comments
 (0)