Skip to content

Commit 3f613ff

Browse files
committed
DATACMNS-1370 - Avoid superflous, regex-based type check while scanning for custom implementations.
1 parent 084b460 commit 3f613ff

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/org/springframework/data/repository/config/CustomRepositoryImplementationDetector.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Optional;
2323
import java.util.Set;
2424
import java.util.function.Function;
25-
import java.util.regex.Pattern;
2625
import java.util.stream.Collectors;
2726

2827
import javax.annotation.Nullable;
@@ -33,7 +32,6 @@
3332
import org.springframework.core.env.Environment;
3433
import org.springframework.core.io.ResourceLoader;
3534
import org.springframework.core.type.classreading.MetadataReaderFactory;
36-
import org.springframework.core.type.filter.RegexPatternTypeFilter;
3735
import org.springframework.core.type.filter.TypeFilter;
3836
import org.springframework.data.util.Streamable;
3937
import org.springframework.util.Assert;
@@ -51,7 +49,7 @@
5149
@RequiredArgsConstructor
5250
public class CustomRepositoryImplementationDetector {
5351

54-
private static final String CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN = "**/*%s.class";
52+
private static final String CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN = "**/%s.class";
5553
private static final String AMBIGUOUS_CUSTOM_IMPLEMENTATIONS = "Ambiguous custom implementations detected! Found %s but expected a single implementation!";
5654

5755
private final @NonNull MetadataReaderFactory metadataReaderFactory;
@@ -106,15 +104,14 @@ Set<BeanDefinition> findCandidateBeanDefinitions(String className, Iterable<Stri
106104
Iterable<TypeFilter> excludeFilters) {
107105

108106
// Build pattern to lookup implementation class
109-
Pattern pattern = Pattern.compile(".*\\." + className);
110107

111108
// Build classpath scanner and lookup bean definition
112109
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false,
113110
environment);
114111
provider.setResourceLoader(resourceLoader);
115112
provider.setResourcePattern(String.format(CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN, className));
116113
provider.setMetadataReaderFactory(metadataReaderFactory);
117-
provider.addIncludeFilter(new RegexPatternTypeFilter(pattern));
114+
provider.addIncludeFilter((reader, factory) -> true);
118115

119116
excludeFilters.forEach(it -> provider.addExcludeFilter(it));
120117

0 commit comments

Comments
 (0)