Skip to content

Commit

Permalink
Merge branch '2.7.x' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jun 16, 2023
2 parents 845c97f + f3f8610 commit 691b549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
<hazelcast-client xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-5.0.xsd">

<instance-name>spring-boot</instance-name>

<connection-strategy>
<connection-retry>
<cluster-connect-timeout-millis>60000</cluster-connect-timeout-millis>
</connection-retry>
</connection-strategy>

<network>
<cluster-members>
<address>${address}</address>
</cluster-members>
</network>

</hazelcast-client>
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ private IgnoreTopLevelConverterNotFoundBindHandler getHandler() {
: new IgnoreTopLevelConverterNotFoundBindHandler();
}

@SuppressWarnings("unchecked")
private List<Validator> getValidators(Bindable<?> target) {
List<Validator> validators = new ArrayList<>(3);
if (this.configurationPropertiesValidator != null) {
Expand All @@ -144,15 +143,23 @@ private List<Validator> getValidators(Bindable<?> target) {
if (this.jsr303Present && target.getAnnotation(Validated.class) != null) {
validators.add(getJsr303Validator());
}
Validator selfValidator = getSelfValidator(target);
if (selfValidator != null) {
validators.add(selfValidator);
}
return validators;
}

private Validator getSelfValidator(Bindable<?> target) {
if (target.getValue() != null) {
if (target.getValue().get() instanceof Validator validator) {
validators.add(validator);
}
Object value = target.getValue().get();
return (value instanceof Validator validator) ? validator : null;
}
else if (Validator.class.isAssignableFrom(target.getType().resolve())) {
validators.add(new SelfValidatingConstructorBoundBindableValidator((Bindable<? extends Validator>) target));
Class<?> type = target.getType().resolve();
if (Validator.class.isAssignableFrom(type)) {
return new SelfValidatingConstructorBoundBindableValidator(type);
}
return validators;
return null;
}

private Validator getJsr303Validator() {
Expand Down Expand Up @@ -263,15 +270,15 @@ public ConfigurationPropertiesBinder getObject() throws Exception {
*/
static class SelfValidatingConstructorBoundBindableValidator implements Validator {

private final Bindable<? extends Validator> bindable;
private final Class<?> type;

SelfValidatingConstructorBoundBindableValidator(Bindable<? extends Validator> bindable) {
this.bindable = bindable;
SelfValidatingConstructorBoundBindableValidator(Class<?> type) {
this.type = type;
}

@Override
public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(this.bindable.getType().resolve());
public boolean supports(Class<?> candidate) {
return candidate.isAssignableFrom(this.type);
}

@Override
Expand Down

0 comments on commit 691b549

Please sign in to comment.