Add additional ElementExcludeFilter items
Fixes gh-2088
This commit is contained in:
parent
2b91471286
commit
f0bc3c08e1
@ -179,7 +179,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
|||||||
VariableElement field = members.getFields().get(name);
|
VariableElement field = members.getFields().get(name);
|
||||||
Element returnType = this.processingEnv.getTypeUtils().asElement(
|
Element returnType = this.processingEnv.getTypeUtils().asElement(
|
||||||
getter.getReturnType());
|
getter.getReturnType());
|
||||||
boolean isExcluded = this.elementExcludeFilter.isExcluded(returnType);
|
boolean isExcluded = this.elementExcludeFilter.isExcluded(getter
|
||||||
|
.getReturnType());
|
||||||
boolean isNested = isNested(returnType, field, element);
|
boolean isNested = isNested(returnType, field, element);
|
||||||
boolean isCollection = this.typeUtils.isCollectionOrMap(getter
|
boolean isCollection = this.typeUtils.isCollectionOrMap(getter
|
||||||
.getReturnType());
|
.getReturnType());
|
||||||
|
@ -19,7 +19,7 @@ package org.springframework.boot.configurationprocessor;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter to excluded elements that don't make sense to process.
|
* Filter to excluded elements that don't make sense to process.
|
||||||
@ -34,19 +34,32 @@ class ElementExcludeFilter {
|
|||||||
public ElementExcludeFilter() {
|
public ElementExcludeFilter() {
|
||||||
add("java.io.Writer");
|
add("java.io.Writer");
|
||||||
add("java.io.PrintWriter");
|
add("java.io.PrintWriter");
|
||||||
add("javax.sql.DataSource");
|
|
||||||
add("java.lang.ClassLoader");
|
add("java.lang.ClassLoader");
|
||||||
|
add("java.util.concurrent.ThreadFactory");
|
||||||
|
add("javax.sql.DataSource");
|
||||||
|
add("com.zaxxer.hikari.IConnectionCustomizer");
|
||||||
|
add("groovy.text.markup.MarkupTemplateEngine");
|
||||||
|
add("org.apache.tomcat.jdbc.pool.PoolConfiguration");
|
||||||
|
add("org.apache.tomcat.jdbc.pool.Validator");
|
||||||
|
add("org.flywaydb.core.api.MigrationVersion");
|
||||||
|
add("org.flywaydb.core.api.callback.FlywayCallback");
|
||||||
|
add("org.flywaydb.core.api.resolver.MigrationResolver");
|
||||||
|
add("org.springframework.http.MediaType");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(String className) {
|
private void add(String className) {
|
||||||
this.excludes.add(className);
|
this.excludes.add(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExcluded(Element element) {
|
public boolean isExcluded(TypeMirror type) {
|
||||||
if (element == null) {
|
if (type == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.excludes.contains(element.toString());
|
String typeName = type.toString();
|
||||||
|
if (typeName.endsWith("[]")) {
|
||||||
|
typeName = typeName.substring(0, typeName.length() - 2);
|
||||||
|
}
|
||||||
|
return this.excludes.contains(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
|||||||
assertThat(metadata, not(containsProperty("excluded.data-source")));
|
assertThat(metadata, not(containsProperty("excluded.data-source")));
|
||||||
assertThat(metadata, not(containsProperty("excluded.print-writer")));
|
assertThat(metadata, not(containsProperty("excluded.print-writer")));
|
||||||
assertThat(metadata, not(containsProperty("excluded.writer")));
|
assertThat(metadata, not(containsProperty("excluded.writer")));
|
||||||
|
assertThat(metadata, not(containsProperty("excluded.writer-array")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigurationMetadata compile(Class<?>... types) throws IOException {
|
private ConfigurationMetadata compile(Class<?>... types) throws IOException {
|
||||||
|
@ -42,6 +42,8 @@ public class ExcludedTypesPojo {
|
|||||||
|
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
|
|
||||||
|
private Writer[] writerArray;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -82,4 +84,12 @@ public class ExcludedTypesPojo {
|
|||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Writer[] getWriterArray() {
|
||||||
|
return this.writerArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWriterArray(Writer[] writerArray) {
|
||||||
|
this.writerArray = writerArray;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user