Prevent StackOverFlowException in metadata processor
Fixes gh-11037
This commit is contained in:
parent
13f45e6434
commit
8b29823885
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties;
|
||||
|
@ -115,7 +114,6 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("gh-11037")
|
||||
public void testCycle() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(CycleConfig.class);
|
||||
|
@ -516,7 +514,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Bean
|
||||
// gh-11037
|
||||
// @ConfigurationProperties(prefix = "cycle")
|
||||
@ConfigurationProperties(prefix = "cycle")
|
||||
public Cycle cycle() {
|
||||
return new Cycle();
|
||||
}
|
||||
|
|
|
@ -468,10 +468,23 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||
if (hasAnnotation(field, nestedConfigurationPropertyAnnotation())) {
|
||||
return true;
|
||||
}
|
||||
if (isCyclePresent(returnType, element)) {
|
||||
return false;
|
||||
}
|
||||
return (isParentTheSame(returnType, element))
|
||||
&& returnType.getKind() != ElementKind.ENUM;
|
||||
}
|
||||
|
||||
private boolean isCyclePresent(Element returnType, Element element) {
|
||||
if (!(element.getEnclosingElement() instanceof TypeElement)) {
|
||||
return false;
|
||||
}
|
||||
if (element.getEnclosingElement().equals(returnType)) {
|
||||
return true;
|
||||
}
|
||||
return isCyclePresent(returnType, element.getEnclosingElement());
|
||||
}
|
||||
|
||||
private boolean isParentTheSame(Element returnType, TypeElement element) {
|
||||
if (returnType == null || element == null) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue