Commit 85ef54a9 by Dave Syer

Fix Feign validation for Spring 4.2 and 4.3

There is a utility method in Spring that we can use to merge all the aliases. That way 4.2 and 4.3 behave the same way. Fixes gh-1192
parent 2f581a11
......@@ -40,6 +40,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
......@@ -154,6 +155,8 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(
FeignClient.class.getCanonicalName());
// Spring 4.2 didn't do this for us. With 4.3 it's idempotent.
attributes = AnnotationAttributes.fromMap(attributes);
String name = getClientName(attributes);
registerClientConfiguration(registry, name,
......@@ -193,10 +196,6 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
Assert.isTrue(!StringUtils.hasText((String) attributes.get("serviceId")),
"Either name (serviceId) or value can be specified, but not both");
}
if (StringUtils.hasText((String) attributes.get("name"))) {
Assert.isTrue(!StringUtils.hasText((String) attributes.get("serviceId")),
"Either name or serviceId can be specified, but not both");
}
}
private String getName(Map<String, Object> attributes) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment