Skip to content

Commit

Permalink
Bumping versions
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-builds committed Jul 22, 2024
1 parent e1f4bfc commit eab1283
Show file tree
Hide file tree
Showing 66 changed files with 672 additions and 515 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,20 @@ public okhttp3.OkHttpClient okHttpClient(okhttp3.OkHttpClient.Builder builder, C
int connectTimeout = httpClientProperties.getConnectionTimeout();
boolean disableSslValidation = httpClientProperties.isDisableSslValidation();
Duration readTimeout = httpClientProperties.getOkHttp().getReadTimeout();
List<Protocol> protocols = httpClientProperties.getOkHttp().getProtocols().stream().map(Protocol::valueOf)
.collect(Collectors.toList());
List<Protocol> protocols = httpClientProperties.getOkHttp()
.getProtocols()
.stream()
.map(Protocol::valueOf)
.collect(Collectors.toList());
if (disableSslValidation) {
disableSsl(builder);
}
this.okHttpClient = builder.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
.followRedirects(followRedirects).readTimeout(readTimeout).connectionPool(connectionPool)
.protocols(protocols).build();
.followRedirects(followRedirects)
.readTimeout(readTimeout)
.connectionPool(connectionPool)
.protocols(protocols)
.build();
return this.okHttpClient;
}

Expand Down Expand Up @@ -415,11 +421,12 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (!ClassUtils.isPresent("feign.Feign", classLoader)) {
return;
}
hints.reflection().registerTypes(
Set.of(TypeReference.of(FeignClientFactoryBean.class),
TypeReference.of(ResponseInterceptor.Chain.class), TypeReference.of(Capability.class)),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
hints.reflection()
.registerTypes(
Set.of(TypeReference.of(FeignClientFactoryBean.class),
TypeReference.of(ResponseInterceptor.Chain.class), TypeReference.of(Capability.class)),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ private <T> T getFromContext(String fallbackMechanism, String feignClientName, F
}

private FeignCircuitBreaker.Builder builder(String feignClientName, FeignCircuitBreaker.Builder builder) {
return builder.circuitBreakerFactory(circuitBreakerFactory).feignClientName(feignClientName)
.circuitBreakerGroupEnabled(circuitBreakerGroupEnabled)
.circuitBreakerNameResolver(circuitBreakerNameResolver);
return builder.circuitBreakerFactory(circuitBreakerFactory)
.feignClientName(feignClientName)
.circuitBreakerGroupEnabled(circuitBreakerGroupEnabled)
.circuitBreakerNameResolver(circuitBreakerNameResolver);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public <T> T getInstance(String contextName, String beanName, Class<T> type) {
public FeignClientFactory withApplicationContextInitializers(Map<String, Object> applicationContextInitializers) {
Map<String, ApplicationContextInitializer<GenericApplicationContext>> convertedInitializers = new HashMap<>();
applicationContextInitializers.keySet()
.forEach(contextId -> convertedInitializers.put(contextId,
(ApplicationContextInitializer<GenericApplicationContext>) applicationContextInitializers
.get(contextId)));
.forEach(contextId -> convertedInitializers.put(contextId,
(ApplicationContextInitializer<GenericApplicationContext>) applicationContextInitializers
.get(contextId)));
return new FeignClientFactory(convertedInitializers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ private void applyBuildCustomizers(FeignClientFactory context, Feign.Builder bui
FeignBuilderCustomizer.class);

if (customizerMap != null) {
customizerMap.values().stream().sorted(AnnotationAwareOrderComparator.INSTANCE)
.forEach(feignBuilderCustomizer -> feignBuilderCustomizer.customize(builder));
customizerMap.values()
.stream()
.sorted(AnnotationAwareOrderComparator.INSTANCE)
.forEach(feignBuilderCustomizer -> feignBuilderCustomizer.customize(builder));
}
additionalCustomizers.forEach(customizer -> customizer.customize(builder));
}
Expand Down Expand Up @@ -244,8 +246,10 @@ protected void configureUsingConfiguration(FeignClientFactory context, Feign.Bui

Map<String, Capability> capabilities = getInheritedAwareInstances(context, Capability.class);
if (capabilities != null) {
capabilities.values().stream().sorted(AnnotationAwareOrderComparator.INSTANCE)
.forEach(builder::addCapability);
capabilities.values()
.stream()
.sorted(AnnotationAwareOrderComparator.INSTANCE)
.forEach(builder::addCapability);
}
}

Expand Down Expand Up @@ -334,7 +338,7 @@ protected void configureDefaultRequestElements(FeignClientProperties.FeignClient
Map<String, Collection<String>> defaultRequestHeaders = new HashMap<>();
if (defaultConfig != null) {
defaultConfig.getDefaultRequestHeaders()
.forEach((k, v) -> defaultRequestHeaders.put(k, new ArrayList<>(v)));
.forEach((k, v) -> defaultRequestHeaders.put(k, new ArrayList<>(v)));
}
if (clientConfig != null) {
clientConfig.getDefaultRequestHeaders().forEach((k, v) -> defaultRequestHeaders.put(k, new ArrayList<>(v)));
Expand All @@ -346,11 +350,11 @@ protected void configureDefaultRequestElements(FeignClientProperties.FeignClient
Map<String, Collection<String>> defaultQueryParameters = new HashMap<>();
if (defaultConfig != null) {
defaultConfig.getDefaultQueryParameters()
.forEach((k, v) -> defaultQueryParameters.put(k, new ArrayList<>(v)));
.forEach((k, v) -> defaultQueryParameters.put(k, new ArrayList<>(v)));
}
if (clientConfig != null) {
clientConfig.getDefaultQueryParameters()
.forEach((k, v) -> defaultQueryParameters.put(k, new ArrayList<>(v)));
.forEach((k, v) -> defaultQueryParameters.put(k, new ArrayList<>(v)));
}
if (!defaultQueryParameters.isEmpty()) {
addDefaultQueryParams(defaultQueryParameters, builder);
Expand Down Expand Up @@ -686,15 +690,48 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("FeignClientFactoryBean{").append("type=").append(type).append(", ").append("name='")
.append(name).append("', ").append("url='").append(url).append("', ").append("path='").append(path)
.append("', ").append("dismiss404=").append(dismiss404).append(", ").append("inheritParentContext=")
.append(inheritParentContext).append(", ").append("applicationContext=").append(applicationContext)
.append(", ").append("beanFactory=").append(beanFactory).append(", ").append("fallback=")
.append(fallback).append(", ").append("fallbackFactory=").append(fallbackFactory).append("}")
.append("connectTimeoutMillis=").append(connectTimeoutMillis).append("}").append("readTimeoutMillis=")
.append(readTimeoutMillis).append("}").append("followRedirects=").append(followRedirects)
.append("refreshableClient=").append(refreshableClient).append("}").toString();
return new StringBuilder("FeignClientFactoryBean{").append("type=")
.append(type)
.append(", ")
.append("name='")
.append(name)
.append("', ")
.append("url='")
.append(url)
.append("', ")
.append("path='")
.append(path)
.append("', ")
.append("dismiss404=")
.append(dismiss404)
.append(", ")
.append("inheritParentContext=")
.append(inheritParentContext)
.append(", ")
.append("applicationContext=")
.append(applicationContext)
.append(", ")
.append("beanFactory=")
.append(beanFactory)
.append(", ")
.append("fallback=")
.append(fallback)
.append(", ")
.append("fallbackFactory=")
.append(fallbackFactory)
.append("}")
.append("connectTimeoutMillis=")
.append(connectTimeoutMillis)
.append("}")
.append("readTimeoutMillis=")
.append(readTimeoutMillis)
.append("}")
.append("followRedirects=")
.append(followRedirects)
.append("refreshableClient=")
.append(refreshableClient)
.append("}")
.toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class FeignClientMicrometerEnabledCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
FeignClientProperties feignClientProperties = context.getBeanFactory()
.getBeanProvider(FeignClientProperties.class).getIfAvailable();
.getBeanProvider(FeignClientProperties.class)
.getIfAvailable();
if (feignClientProperties != null) {
Map<String, FeignClientProperties.FeignClientConfiguration> feignClientConfigMap = feignClientProperties
.getConfig();
.getConfig();
if (feignClientConfigMap != null) {
FeignClientProperties.FeignClientConfiguration feignClientConfig = feignClientConfigMap
.get(context.getEnvironment().getProperty("spring.cloud.openfeign.client.name"));
.get(context.getEnvironment().getProperty("spring.cloud.openfeign.client.name"));
if (feignClientConfig != null) {
FeignClientProperties.MicrometerProperties micrometer = feignClientConfig.getMicrometer();
if (micrometer != null && micrometer.getEnabled() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void registerFeignClients(AnnotationMetadata metadata, BeanDefinitionRegi
Assert.isTrue(annotationMetadata.isInterface(), "@FeignClient can only be specified on an interface");

Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(FeignClient.class.getCanonicalName());
.getAnnotationAttributes(FeignClient.class.getCanonicalName());

String name = getClientName(attributes);
String className = annotationMetadata.getClassName();
Expand All @@ -206,8 +206,9 @@ public void registerFeignClients(AnnotationMetadata metadata, BeanDefinitionRegi
private void registerFeignClient(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata,
Map<String, Object> attributes) {
String className = annotationMetadata.getClassName();
if (String.valueOf(false).equals(
environment.getProperty("spring.cloud.openfeign.lazy-attributes-resolution", String.valueOf(false)))) {
if (String.valueOf(false)
.equals(environment.getProperty("spring.cloud.openfeign.lazy-attributes-resolution",
String.valueOf(false)))) {
eagerlyRegisterFeignClientBeanDefinition(className, attributes, registry);
}
else {
Expand Down Expand Up @@ -392,7 +393,7 @@ protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {

protected Set<String> getBasePackages(AnnotationMetadata importingClassMetadata) {
Map<String, Object> attributes = importingClassMetadata
.getAnnotationAttributes(EnableFeignClients.class.getCanonicalName());
.getAnnotationAttributes(EnableFeignClients.class.getCanonicalName());

Set<String> basePackages = new HashSet<>();
for (String pkg : (String[]) attributes.get("value")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ public boolean processArgument(AnnotatedParameterContext context, Annotation ann
String name = cookie.value().trim();
checkState(emptyToNull(name) != null, "Cookie.name() was empty on parameter %s", parameterIndex);
context.setParameterName(name);
String cookieExpression = data.template().headers()
.getOrDefault(HttpHeaders.COOKIE, Collections.singletonList("")).stream().findFirst().orElse("");
String cookieExpression = data.template()
.headers()
.getOrDefault(HttpHeaders.COOKIE, Collections.singletonList(""))
.stream()
.findFirst()
.orElse("");
if (cookieExpression.length() == 0) {
cookieExpression = String.format("%s={%s}", name, name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public boolean processArgument(AnnotatedParameterContext context, Annotation ann
private String expandMap(Object object) {
Map<String, Object> paramMap = (Map) object;

return paramMap.keySet().stream().filter(key -> paramMap.get(key) != null)
.map(key -> ";" + key + "=" + paramMap.get(key).toString()).collect(Collectors.joining());
return paramMap.keySet()
.stream()
.filter(key -> paramMap.get(key) != null)
.map(key -> ";" + key + "=" + paramMap.get(key).toString())
.collect(Collectors.joining());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registe
}
Set<String> contextIds = new HashSet<>(getContextIdsFromConfig());
Map<String, GenericApplicationContext> childContextAotContributions = contextIds.stream()
.map(contextId -> Map.entry(contextId, buildChildContext(contextId)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
.map(contextId -> Map.entry(contextId, buildChildContext(contextId)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return new AotContribution(childContextAotContributions);
}

Expand All @@ -91,9 +91,11 @@ private static class AotContribution implements BeanRegistrationAotContribution
private final Map<String, GenericApplicationContext> childContexts;

AotContribution(Map<String, GenericApplicationContext> childContexts) {
this.childContexts = childContexts.entrySet().stream().filter(entry -> entry.getValue() != null)
.map(entry -> Map.entry(entry.getKey(), entry.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
this.childContexts = childContexts.entrySet()
.stream()
.filter(entry -> entry.getValue() != null)
.map(entry -> Map.entry(entry.getKey(), entry.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

@Override
Expand All @@ -103,21 +105,22 @@ public void applyTo(GenerationContext generationContext, BeanRegistrationCode be
name = name.replaceAll("[-]", "_");
GenerationContext childGenerationContext = generationContext.withName(name);
ClassName initializerClassName = new ApplicationContextAotGenerator()
.processAheadOfTime(entry.getValue(), childGenerationContext);
.processAheadOfTime(entry.getValue(), childGenerationContext);
return Map.entry(entry.getKey(), initializerClassName);
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods()
.add("addFeignChildContextInitializer", method -> {
method.addJavadoc("Use AOT child context management initialization")
.addModifiers(Modifier.PRIVATE, Modifier.STATIC)
.addParameter(RegisteredBean.class, "registeredBean")
.addParameter(FeignClientFactory.class, "instance").returns(FeignClientFactory.class)
.addStatement("$T<String, Object> initializers = new $T<>()", Map.class, HashMap.class);
generatedInitializerClassNames.keySet()
.forEach(contextId -> method.addStatement("initializers.put($S, new $L())", contextId,
generatedInitializerClassNames.get(contextId)));
method.addStatement("return instance.withApplicationContextInitializers(initializers)");
});
.add("addFeignChildContextInitializer", method -> {
method.addJavadoc("Use AOT child context management initialization")
.addModifiers(Modifier.PRIVATE, Modifier.STATIC)
.addParameter(RegisteredBean.class, "registeredBean")
.addParameter(FeignClientFactory.class, "instance")
.returns(FeignClientFactory.class)
.addStatement("$T<String, Object> initializers = new $T<>()", Map.class, HashMap.class);
generatedInitializerClassNames.keySet()
.forEach(contextId -> method.addStatement("initializers.put($S, new $L())", contextId,
generatedInitializerClassNames.get(contextId)));
method.addStatement("return instance.withApplicationContextInitializers(initializers)");
});
beanRegistrationCode.addInstancePostProcessor(postProcessorMethod.toMethodReference());
}

Expand Down
Loading

0 comments on commit eab1283

Please sign in to comment.