From 343046d30ccdd9ee3612b6915a3bc0235bef25ce Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sat, 14 Oct 2023 19:51:42 -0700 Subject: [PATCH] Polish --- ...viceConnectionContextCustomizerFactory.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizerFactory.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizerFactory.java index c54c77b0451..1f18f06c1a0 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizerFactory.java @@ -49,26 +49,26 @@ class ServiceConnectionContextCustomizerFactory implements ContextCustomizerFact public ContextCustomizer createContextCustomizer(Class testClass, List configAttributes) { List> sources = new ArrayList<>(); - findSources(testClass, sources); + collectSources(testClass, sources); return new ServiceConnectionContextCustomizer(sources); } - private void findSources(Class clazz, List> sources) { - if (clazz == Object.class || clazz == null) { + private void collectSources(Class candidate, List> sources) { + if (candidate == Object.class || candidate == null) { return; } - ReflectionUtils.doWithLocalFields(clazz, (field) -> { + ReflectionUtils.doWithLocalFields(candidate, (field) -> { MergedAnnotations annotations = MergedAnnotations.from(field); annotations.stream(ServiceConnection.class) .forEach((annotation) -> sources.add(createSource(field, annotation))); }); - if (TestContextAnnotationUtils.searchEnclosingClass(clazz)) { - findSources(clazz.getEnclosingClass(), sources); + if (TestContextAnnotationUtils.searchEnclosingClass(candidate)) { + collectSources(candidate.getEnclosingClass(), sources); } - for (Class implementedInterface : clazz.getInterfaces()) { - findSources(implementedInterface, sources); + for (Class implementedInterface : candidate.getInterfaces()) { + collectSources(implementedInterface, sources); } - findSources(clazz.getSuperclass(), sources); + collectSources(candidate.getSuperclass(), sources); } @SuppressWarnings("unchecked")