Skip to content

Commit 5ab7076

Browse files
committed
considerInterfaces should work without considerInherited as well
Issue: SPR-11719
1 parent 945335d commit 5ab7076

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

spring-core/src/main/java/org/springframework/core/type/filter/AbstractTypeHierarchyTraversingFilter.java

+29-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
1919
import java.io.IOException;
2020

2121
import org.springframework.core.type.ClassMetadata;
22-
import org.springframework.core.type.classreading.MetadataReaderFactory;
2322
import org.springframework.core.type.classreading.MetadataReader;
23+
import org.springframework.core.type.classreading.MetadataReaderFactory;
2424

2525
/**
2626
* Type filter that is aware of traversing over hierarchy.
@@ -61,40 +61,38 @@ public boolean match(MetadataReader metadataReader, MetadataReaderFactory metada
6161
return true;
6262
}
6363

64-
if (!this.considerInherited) {
65-
return false;
66-
}
67-
if (metadata.hasSuperClass()) {
68-
// Optimization to avoid creating ClassReader for super class.
69-
Boolean superClassMatch = matchSuperClass(metadata.getSuperClassName());
70-
if (superClassMatch != null) {
71-
if (superClassMatch.booleanValue()) {
72-
return true;
64+
if (this.considerInherited) {
65+
if (metadata.hasSuperClass()) {
66+
// Optimization to avoid creating ClassReader for super class.
67+
Boolean superClassMatch = matchSuperClass(metadata.getSuperClassName());
68+
if (superClassMatch != null) {
69+
if (superClassMatch.booleanValue()) {
70+
return true;
71+
}
7372
}
74-
}
75-
else {
76-
// Need to read super class to determine a match...
77-
if (match(metadata.getSuperClassName(), metadataReaderFactory)) {
78-
return true;
73+
else {
74+
// Need to read super class to determine a match...
75+
if (match(metadata.getSuperClassName(), metadataReaderFactory)) {
76+
return true;
77+
}
7978
}
8079
}
8180
}
8281

83-
if (!this.considerInterfaces) {
84-
return false;
85-
}
86-
for (String ifc : metadata.getInterfaceNames()) {
87-
// Optimization to avoid creating ClassReader for super class
88-
Boolean interfaceMatch = matchInterface(ifc);
89-
if (interfaceMatch != null) {
90-
if (interfaceMatch.booleanValue()) {
91-
return true;
82+
if (this.considerInterfaces) {
83+
for (String ifc : metadata.getInterfaceNames()) {
84+
// Optimization to avoid creating ClassReader for super class
85+
Boolean interfaceMatch = matchInterface(ifc);
86+
if (interfaceMatch != null) {
87+
if (interfaceMatch.booleanValue()) {
88+
return true;
89+
}
9290
}
93-
}
94-
else {
95-
// Need to read interface to determine a match...
96-
if (match(ifc, metadataReaderFactory)) {
97-
return true;
91+
else {
92+
// Need to read interface to determine a match...
93+
if (match(ifc, metadataReaderFactory)) {
94+
return true;
95+
}
9896
}
9997
}
10098
}
@@ -132,7 +130,7 @@ protected Boolean matchSuperClass(String superClassName) {
132130
/**
133131
* Override this to match on interface type name.
134132
*/
135-
protected Boolean matchInterface(String interfaceNames) {
133+
protected Boolean matchInterface(String interfaceName) {
136134
return null;
137135
}
138136

0 commit comments

Comments
 (0)