Prevent StackOverFlowException in metadata processor

Fixes gh-11037
This commit is contained in:
Madhura Bhave
2018-03-27 10:56:29 -07:00
parent 13f45e6434
commit 8b29823885
2 changed files with 14 additions and 3 deletions

View File

@@ -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;