Skip to content

Commit

Permalink
Merge branch '2.6.x' into 2.7.x
Browse files Browse the repository at this point in the history
Closes gh-29144
  • Loading branch information
scottfrederick committed Dec 20, 2021
2 parents f4e28be + b3a304f commit 29ad847
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ protected void addProperties(Method[] declaredMethods, Field[] declaredFields) {
private boolean isCandidate(Method method) {
int modifiers = method.getModifiers();
return !Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isAbstract(modifiers)
&& !Modifier.isStatic(modifiers) && !Object.class.equals(method.getDeclaringClass())
&& !Modifier.isStatic(modifiers) && !method.isBridge()
&& !Object.class.equals(method.getDeclaringClass())
&& !Class.class.equals(method.getDeclaringClass()) && method.getName().indexOf('$') == -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ void bindToInstanceWhenNoNestedShouldLeaveNestedAsNull() {
assertThat(bean.getValueBean()).isNull();
}

@Test
void bindToClassWithOverriddenPropertyShouldSetSubclassProperty() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.value-bean.int-value", "123");
source.put("foo.value-bean.sub-int-value", "456");
this.sources.add(source);
ExampleNestedSubclassBean bean = this.binder.bind("foo", Bindable.of(ExampleNestedSubclassBean.class)).get();
assertThat(bean.getValueBean()).isNotNull();
assertThat(bean.getValueBean().getIntValue()).isEqualTo(123);
assertThat(bean.getValueBean().getSubIntValue()).isEqualTo(456);
}

@Test
void bindToClassWhenPropertiesMissingShouldReturnUnbound() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
Expand Down Expand Up @@ -804,6 +816,35 @@ String getFoo() {

}

static class ExampleNestedSubclassBean extends ExampleNestedBean {

private ExampleValueSubclassBean valueBean;

@Override
ExampleValueSubclassBean getValueBean() {
return this.valueBean;
}

void setValueBean(ExampleValueSubclassBean valueBean) {
this.valueBean = valueBean;
}

static class ExampleValueSubclassBean extends ExampleValueBean {

private int subIntValue;

int getSubIntValue() {
return this.subIntValue;
}

void setSubIntValue(int intValue) {
this.subIntValue = intValue;
}

}

}

static class ExampleWithNonDefaultConstructor {

private String value;
Expand Down

0 comments on commit 29ad847

Please sign in to comment.