Skip to content

Commit 691b549

Browse files
committed
Merge branch '2.7.x' into 3.0.x
2 parents 845c97f + f3f8610 commit 691b549

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/hazelcast/hazelcast-client-instance.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
<hazelcast-client xmlns="http://www.hazelcast.com/schema/client-config"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-5.0.xsd">
5-
65
<instance-name>spring-boot</instance-name>
7-
86
<connection-strategy>
97
<connection-retry>
108
<cluster-connect-timeout-millis>60000</cluster-connect-timeout-millis>
119
</connection-retry>
1210
</connection-strategy>
13-
1411
<network>
1512
<cluster-members>
1613
<address>${address}</address>
1714
</cluster-members>
1815
</network>
19-
2016
</hazelcast-client>

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ private IgnoreTopLevelConverterNotFoundBindHandler getHandler() {
135135
: new IgnoreTopLevelConverterNotFoundBindHandler();
136136
}
137137

138-
@SuppressWarnings("unchecked")
139138
private List<Validator> getValidators(Bindable<?> target) {
140139
List<Validator> validators = new ArrayList<>(3);
141140
if (this.configurationPropertiesValidator != null) {
@@ -144,15 +143,23 @@ private List<Validator> getValidators(Bindable<?> target) {
144143
if (this.jsr303Present && target.getAnnotation(Validated.class) != null) {
145144
validators.add(getJsr303Validator());
146145
}
146+
Validator selfValidator = getSelfValidator(target);
147+
if (selfValidator != null) {
148+
validators.add(selfValidator);
149+
}
150+
return validators;
151+
}
152+
153+
private Validator getSelfValidator(Bindable<?> target) {
147154
if (target.getValue() != null) {
148-
if (target.getValue().get() instanceof Validator validator) {
149-
validators.add(validator);
150-
}
155+
Object value = target.getValue().get();
156+
return (value instanceof Validator validator) ? validator : null;
151157
}
152-
else if (Validator.class.isAssignableFrom(target.getType().resolve())) {
153-
validators.add(new SelfValidatingConstructorBoundBindableValidator((Bindable<? extends Validator>) target));
158+
Class<?> type = target.getType().resolve();
159+
if (Validator.class.isAssignableFrom(type)) {
160+
return new SelfValidatingConstructorBoundBindableValidator(type);
154161
}
155-
return validators;
162+
return null;
156163
}
157164

158165
private Validator getJsr303Validator() {
@@ -263,15 +270,15 @@ public ConfigurationPropertiesBinder getObject() throws Exception {
263270
*/
264271
static class SelfValidatingConstructorBoundBindableValidator implements Validator {
265272

266-
private final Bindable<? extends Validator> bindable;
273+
private final Class<?> type;
267274

268-
SelfValidatingConstructorBoundBindableValidator(Bindable<? extends Validator> bindable) {
269-
this.bindable = bindable;
275+
SelfValidatingConstructorBoundBindableValidator(Class<?> type) {
276+
this.type = type;
270277
}
271278

272279
@Override
273-
public boolean supports(Class<?> clazz) {
274-
return clazz.isAssignableFrom(this.bindable.getType().resolve());
280+
public boolean supports(Class<?> candidate) {
281+
return candidate.isAssignableFrom(this.type);
275282
}
276283

277284
@Override

0 commit comments

Comments
 (0)