Compare commits

...
33 changed files with 213 additions and 93 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-netflix-docs</artifactId>
<packaging>pom</packaging>
+5 -5
View File
@@ -3,14 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<packaging>pom</packaging>
<name>Spring Cloud Netflix</name>
<description>Spring Cloud Netflix</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>2.3.4.RELEASE</version>
<version>2.3.5.RELEASE</version>
<relativePath />
</parent>
<scm>
@@ -21,9 +21,9 @@
</scm>
<properties>
<bintray.package>netflix</bintray.package>
<spring-cloud-commons.version>2.2.9.BUILD-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-config.version>2.2.9.BUILD-SNAPSHOT</spring-cloud-config.version>
<spring-cloud-stream.version>Horsham.SR12</spring-cloud-stream.version>
<spring-cloud-commons.version>2.2.9.RELEASE</spring-cloud-commons.version>
<spring-cloud-config.version>2.2.8.RELEASE</spring-cloud-config.version>
<spring-cloud-stream.version>Horsham.SR13</spring-cloud-stream.version>
<!-- Has to be a stable version (not one that depends on this version of netflix): -->
<donotreplacespring-cloud-contract.version>2.2.4.RELEASE</donotreplacespring-cloud-contract.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<artifactId>spring-cloud-netflix</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-concurrency-limits</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-core</artifactId>
+2 -2
View File
@@ -5,11 +5,11 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>2.3.5.BUILD-SNAPSHOT</version>
<version>2.3.5.RELEASE</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-netflix-dependencies</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<packaging>pom</packaging>
<name>spring-cloud-netflix-dependencies</name>
<description>Spring Cloud Netflix Dependencies</description>
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-client-tls-tests</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-server</artifactId>
@@ -5,11 +5,11 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>2.3.4.RELEASE</version>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-hystrix-contract</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<packaging>jar</packaging>
<name>spring-cloud-netflix-hystrix-contract</name>
<description>Spring Cloud Netflix Hystrix Contract</description>
@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<dependencies>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-hystrix-stream</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-hystrix</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>spring-cloud-netflix</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -31,6 +31,7 @@ import static org.springframework.cloud.netflix.ribbon.support.RibbonRequestCust
/**
* @author Christian Lohmann
* @author Chintan Radia
*/
public class RibbonApacheHttpRequest extends ContextAwareRequest implements Cloneable {
@@ -62,7 +63,8 @@ public class RibbonApacheHttpRequest extends ContextAwareRequest implements Clon
// if the entity contentLength isn't set, transfer-encoding will be set
// to chunked in org.apache.http.protocol.RequestContent. See gh-1042
Long contentLength = this.context.getContentLength();
if ("GET".equals(this.context.getMethod())
if (("GET".equals(this.context.getMethod())
|| "DELETE".equals(this.context.getMethod()))
&& (contentLength == null || contentLength < 0)) {
entity.setContentLength(0);
}
@@ -39,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Spencer Gibb
* @author Chintan Radia
*/
public class RibbonApacheHttpRequestTests {
@@ -79,6 +80,13 @@ public class RibbonApacheHttpRequestTests {
"GET");
}
@Test
public void testEmptyEntityDelete() throws Exception {
String entityValue = "";
testEntity(entityValue, new ByteArrayInputStream(entityValue.getBytes()), false,
"DELETE");
}
@Test
public void testNonEmptyEntityPost() throws Exception {
String entityValue = "abcd";
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-turbine-stream</artifactId>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-turbine</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<artifactId>spring-cloud-netflix</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
@@ -0,0 +1,102 @@
/*
* Copyright 2013-2020 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.netflix.zuul.filters;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.actuate.trace.http.TraceableRequest;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriUtils;
/**
* @author Alexander Kogut
*/
public class ServletTraceableRequest implements TraceableRequest {
private HttpServletRequest request;
ServletTraceableRequest(HttpServletRequest request) {
this.request = request;
}
@Override
public String getMethod() {
return request.getMethod();
}
@Override
public URI getUri() {
String queryString = request.getQueryString();
if (!StringUtils.hasText(queryString)) {
return URI.create(request.getRequestURL().toString());
}
try {
StringBuffer urlBuffer = appendQueryString(queryString);
return new URI(urlBuffer.toString());
}
catch (URISyntaxException ex) {
String encoded = UriUtils.encode(queryString, StandardCharsets.UTF_8);
StringBuffer urlBuffer = appendQueryString(encoded);
return URI.create(urlBuffer.toString());
}
}
private StringBuffer appendQueryString(String queryString) {
StringBuffer urlBuffer = request.getRequestURL();
urlBuffer.append("?");
urlBuffer.append(queryString);
return urlBuffer;
}
@Override
public Map<String, List<String>> getHeaders() {
return extractHeaders();
}
@Override
public String getRemoteAddress() {
return request.getRemoteAddr();
}
private Map<String, List<String>> extractHeaders() {
Map<String, List<String>> headers = new LinkedHashMap<>();
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
headers.put(name, toList(request.getHeaders(name)));
}
return headers;
}
private List<String> toList(Enumeration<String> enumeration) {
List<String> list = new ArrayList<>();
while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement());
}
return list;
}
}
@@ -19,11 +19,8 @@ package org.springframework.cloud.netflix.zuul.filters;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -37,9 +34,7 @@ import org.springframework.boot.actuate.trace.http.HttpExchangeTracer;
import org.springframework.boot.actuate.trace.http.HttpTrace;
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
import org.springframework.boot.actuate.trace.http.Include;
import org.springframework.boot.actuate.trace.http.TraceableRequest;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
/**
* @author Spencer Gibb
@@ -134,57 +129,4 @@ public class TraceProxyRequestHelper extends ProxyRequestHelper {
}
}
private class ServletTraceableRequest implements TraceableRequest {
private HttpServletRequest request;
ServletTraceableRequest(HttpServletRequest request) {
this.request = request;
}
@Override
public String getMethod() {
return request.getMethod();
}
@Override
public URI getUri() {
StringBuffer urlBuffer = request.getRequestURL();
if (StringUtils.hasText(request.getQueryString())) {
urlBuffer.append("?");
urlBuffer.append(request.getQueryString());
}
return URI.create(urlBuffer.toString());
}
@Override
public Map<String, List<String>> getHeaders() {
return extractHeaders();
}
@Override
public String getRemoteAddress() {
return request.getRemoteAddr();
}
private Map<String, List<String>> extractHeaders() {
Map<String, List<String>> headers = new LinkedHashMap<>();
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
headers.put(name, toList(request.getHeaders(name)));
}
return headers;
}
private List<String> toList(Enumeration<String> enumeration) {
List<String> list = new ArrayList<>();
while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement());
}
return list;
}
}
}
@@ -0,0 +1,66 @@
/*
* Copyright 2013-2020 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.netflix.zuul.filters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ServletTraceableRequest}.
*/
class ServletTraceableRequestTests {
private MockHttpServletRequest request;
@BeforeEach
public void setup() {
request = new MockHttpServletRequest("GET", "/script");
}
@Test
public void getUriWithoutQueryStringShouldReturnUri() {
validate("http://localhost/script");
}
@Test
public void getUriShouldReturnUriWithQueryString() {
request.setQueryString("a=b");
validate("http://localhost/script?a=b");
}
@Test
public void getUriWithSpecialCharactersInQueryStringShouldEncode() {
request.setQueryString("a=${b}");
validate("http://localhost/script?a%3D%24%7Bb%7D");
}
@Test
public void getUriWithSpecialCharactersEncodedShouldNotDoubleEncode() {
request.setQueryString("a%3D%24%7Bb%7D");
validate("http://localhost/script?a%3D%24%7Bb%7D");
}
private void validate(String expectedUri) {
ServletTraceableRequest trace = new ServletTraceableRequest(request);
assertThat(trace.getUri().toString()).isEqualTo(expectedUri);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
<relativePath>..</relativePath>
</parent>
<artifactId>spring-cloud-starter-netflix</artifactId>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-archaius</artifactId>
<name>Spring Cloud Starter Netflix Archaius</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<name>Spring Cloud Starter Netflix Eureka Client</name>
@@ -3,7 +3,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<name>Spring Cloud Starter Netflix Eureka Server</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<name>Spring Cloud Starter Netflix Hystrix Dashboard</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<name>Spring Cloud Starter Netflix Hystrix</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<name>Spring Cloud Starter Netflix Ribbon</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-turbine-stream</artifactId>
<name>Spring Cloud Starter Netflix Turbine Stream</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
<name>Spring Cloud Starter Netflix Turbine</name>
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix</artifactId>
<version>2.2.9.BUILD-SNAPSHOT</version>
<version>2.2.9.RELEASE</version>
</parent>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<name>Spring Cloud Starter Netflix Zuul</name>