upgrade Ribbon to version 2.0.0.
From 2.0.RC13 fixes gh-216
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -26,7 +26,7 @@
|
||||
<eureka.version>1.1.147</eureka.version>
|
||||
<feign.version>7.3.0</feign.version>
|
||||
<hystrix.version>1.4.0</hystrix.version>
|
||||
<ribbon.version>2.0-RC13</ribbon.version>
|
||||
<ribbon.version>2.0.0</ribbon.version>
|
||||
<zuul.version>1.0.28</zuul.version>
|
||||
<netflix.rxjava.version>0.20.7</netflix.rxjava.version>
|
||||
<java.version>1.7</java.version>
|
||||
@@ -238,6 +238,11 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.ribbon</groupId>
|
||||
<artifactId>ribbon-loadbalancer</artifactId>
|
||||
<version>${ribbon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.rxjava</groupId>
|
||||
<artifactId>rxjava-core</artifactId>
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
<artifactId>eureka-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.ribbon</groupId>
|
||||
<artifactId>ribbon-loadbalancer</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- Eureka core deps that are now optional -->
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import com.netflix.client.http.HttpRequest;
|
||||
import com.netflix.client.http.HttpRequest.Builder;
|
||||
import com.netflix.client.http.HttpRequest.Verb;
|
||||
@@ -37,6 +35,7 @@ import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
|
||||
import com.netflix.niws.client.http.RestClient;
|
||||
import com.netflix.zuul.constants.ZuulConstants;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* Hystrix wrapper around Eureka Ribbon command
|
||||
@@ -45,6 +44,7 @@ import com.netflix.zuul.context.RequestContext;
|
||||
* https://github.com/Netflix/zuul/blob/master/zuul-netflix/src/main/java/com/
|
||||
* netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RibbonCommand extends HystrixCommand<HttpResponse> {
|
||||
|
||||
private RestClient restClient;
|
||||
@@ -55,24 +55,24 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
|
||||
|
||||
private Boolean retryable;
|
||||
|
||||
private MultivaluedMap<String, String> headers;
|
||||
private MultiValueMap<String, String> headers;
|
||||
|
||||
private MultivaluedMap<String, String> params;
|
||||
private MultiValueMap<String, String> params;
|
||||
|
||||
private InputStream requestEntity;
|
||||
|
||||
public RibbonCommand(RestClient restClient, Verb verb, String uri,
|
||||
Boolean retryable,
|
||||
MultivaluedMap<String, String> headers,
|
||||
MultivaluedMap<String, String> params, InputStream requestEntity)
|
||||
MultiValueMap<String, String> headers,
|
||||
MultiValueMap<String, String> params, InputStream requestEntity)
|
||||
throws URISyntaxException {
|
||||
this("default", restClient, verb, uri, retryable , headers, params, requestEntity);
|
||||
}
|
||||
|
||||
public RibbonCommand(String commandKey, RestClient restClient, Verb verb, String uri,
|
||||
Boolean retryable,
|
||||
MultivaluedMap<String, String> headers,
|
||||
MultivaluedMap<String, String> params, InputStream requestEntity)
|
||||
MultiValueMap<String, String> headers,
|
||||
MultiValueMap<String, String> params, InputStream requestEntity)
|
||||
throws URISyntaxException {
|
||||
super(getSetter(commandKey));
|
||||
this.restClient = restClient;
|
||||
|
||||
@@ -20,13 +20,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
|
||||
@@ -43,7 +41,6 @@ import com.netflix.niws.client.http.RestClient;
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import com.netflix.zuul.exception.ZuulException;
|
||||
import com.sun.jersey.core.util.MultivaluedMapImpl;
|
||||
|
||||
@CommonsLog
|
||||
public class RibbonRoutingFilter extends ZuulFilter {
|
||||
@@ -125,7 +122,7 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
Map<String, Object> info = this.helper.debug(verb.verb(), uri, headers, params,
|
||||
requestEntity);
|
||||
RibbonCommand command = new RibbonCommand(service, restClient, verb, uri, retryable,
|
||||
convertHeaders(headers), convertHeaders(params), requestEntity);
|
||||
headers, params, requestEntity);
|
||||
try {
|
||||
HttpResponse response = command.execute();
|
||||
this.helper.appendDebug(info, response.getStatus(),
|
||||
@@ -150,18 +147,9 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
|
||||
private MultiValueMap<String, String> revertHeaders(
|
||||
Map<String, Collection<String>> headers) {
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
for (Entry<String, Collection<String>> entry : headers.entrySet()) {
|
||||
map.put(entry.getKey(), new ArrayList<String>(entry.getValue()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private MultivaluedMap<String, String> convertHeaders(
|
||||
MultiValueMap<String, String> headers) {
|
||||
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
|
||||
for (Entry<String, List<String>> entry : headers.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
map.put(entry.getKey(), new ArrayList<>(entry.getValue()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user