minor changes (#1336)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties("spring.cloud.loadbalancer")
|
||||
public class LoadBalancerClientsProperties extends LoadBalancerProperties {
|
||||
|
||||
private Map<String, LoadBalancerProperties> clients = new HashMap<>();
|
||||
private final Map<String, LoadBalancerProperties> clients = new HashMap<>();
|
||||
|
||||
public Map<String, LoadBalancerProperties> getClients() {
|
||||
return this.clients;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,9 +33,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class LoadBalancerInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
private LoadBalancerClient loadBalancer;
|
||||
private final LoadBalancerClient loadBalancer;
|
||||
|
||||
private LoadBalancerRequestFactory requestFactory;
|
||||
private final LoadBalancerRequestFactory requestFactory;
|
||||
|
||||
public LoadBalancerInterceptor(LoadBalancerClient loadBalancer, LoadBalancerRequestFactory requestFactory) {
|
||||
this.loadBalancer = loadBalancer;
|
||||
@@ -48,12 +48,12 @@ public class LoadBalancerInterceptor implements ClientHttpRequestInterceptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
|
||||
final ClientHttpRequestExecution execution) throws IOException {
|
||||
final URI originalUri = request.getURI();
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
|
||||
ClientHttpRequestExecution execution) throws IOException {
|
||||
URI originalUri = request.getURI();
|
||||
String serviceName = originalUri.getHost();
|
||||
Assert.state(serviceName != null, "Request URI does not contain a valid hostname: " + originalUri);
|
||||
return this.loadBalancer.execute(serviceName, this.requestFactory.createRequest(request, body, execution));
|
||||
return loadBalancer.execute(serviceName, requestFactory.createRequest(request, body, execution));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user