Skip to content

Commit

Permalink
Fix null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed Jan 27, 2025
1 parent cc5fae2 commit 1b14b9a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.MultiValueMap;

import java.net.URI;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -89,22 +90,14 @@ public abstract class AbstractClusterRequest<T> extends AbstractHttpOutboundRequ

protected CacheObject<String> stickyId;

/**
* Constructs a new ClientOutboundRequest with the specified parameters.
*
* @param request The original client request to be processed.
* @param loadBalancerFactory A factory for creating instances of ReactiveLoadBalancer for service instances.
*/
public AbstractClusterRequest(T request,
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerFactory) {
this(request, loadBalancerFactory, null);
}

public AbstractClusterRequest(T request,
URI uri,
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerFactory,
LoadBalancerProperties properties) {
super(request);
this.uri = uri;
this.loadBalancerFactory = loadBalancerFactory;
// depend on url
this.properties = buildProperties(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public BlockingClusterRequest(HttpRequest request,
LoadBalancerProperties properties,
byte[] body,
ClientHttpRequestExecution execution) {
super(request, loadBalancerFactory, properties);
this.uri = request.getURI();
super(request, request.getURI(), loadBalancerFactory, properties);
this.body = body;
this.execution = execution;
this.writeableHeaders = HttpHeaders.writableHttpHeaders(request.getHeaders());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ public FeignClusterRequest(Request request,
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerClientFactory,
LoadBalancerProperties properties,
Request.Options options) {
super(request, loadBalancerClientFactory, properties);
super(request, URI.create(request.url()), loadBalancerClientFactory, properties);
this.options = options;
this.uri = URI.create(request.url());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public ReactiveClusterRequest(ClientRequest request,
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerFactory,
LoadBalancerProperties properties,
ExchangeFunction next) {
super(request, loadBalancerFactory, properties);
this.uri = request.url();
super(request, request.url(), loadBalancerFactory, properties);
this.next = next;
this.writeableHeaders = HttpHeaders.writableHttpHeaders(request.headers());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ public GatewayClusterRequest(ServerWebExchange exchange,
GatewayConfig gatewayConfig,
RetryConfig retryConfig,
int index) {
super(exchange.getRequest(), factory, null);
super(exchange.getRequest(), exchange.getAttributeOrDefault(GATEWAY_REQUEST_URL_ATTR, exchange.getRequest().getURI()), factory, null);
this.exchange = exchange;
this.chain = chain;
this.retryConfig = retryConfig;
this.gatewayConfig = gatewayConfig;
this.index = index;
this.uri = exchange.getAttributeOrDefault(GATEWAY_REQUEST_URL_ATTR, exchange.getRequest().getURI());
this.writeableHeaders = HttpHeaders.writableHttpHeaders(request.getHeaders());
}

Expand Down

0 comments on commit 1b14b9a

Please sign in to comment.