Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
5a0af271
Commit
5a0af271
authored
Oct 11, 2016
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'Upstream/master'
parents
50fac81a
18c4bc06
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
13 deletions
+49
-13
spring-cloud-netflix.adoc
docs/src/main/asciidoc/spring-cloud-netflix.adoc
+12
-0
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+4
-5
FormBodyWrapperFilter.java
...cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
+6
-7
RibbonLoadBalancerClientTests.java
...k/cloud/netflix/ribbon/RibbonLoadBalancerClientTests.java
+26
-0
pom.xml
spring-cloud-netflix-dependencies/pom.xml
+1
-1
No files found.
docs/src/main/asciidoc/spring-cloud-netflix.adoc
View file @
5a0af271
...
...
@@ -1758,6 +1758,18 @@ If Spring AOP is enabled and `org.aspectj:aspectjweaver` is present on your runt
3.
URI
,
sanitized
for
Atlas
4.
Client
name
WARNING
:
Avoid
using
hardcoded
url
parameters
within
`
RestTemplate
`.
When
targeting
dynamic
endpoints
use
URL
variables
.
This
will
avoid
potential
"GC Overhead Limit Reached"
issues
where
`
ServoMonitorCache
`
treats
each
url
as
a
unique
key
.
[
source
,
java
,
indent
=
0
]
----
//
recommended
String
orderid
=
"1"
;
restTemplate
.
getForObject
(
"http://testeurekabrixtonclient/orders/{orderid}"
,
String
.
class
,
orderid
)
//
avoid
restTemplate
.
getForObject
(
"http://testeurekabrixtonclient/orders/1"
,
String
.
class
)
----
[[
netflix
-
metrics
-
spectator
]]
===
Metrics
Collection
:
Spectator
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
5a0af271
...
...
@@ -52,11 +52,10 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
RibbonLoadBalancerContext
context
=
this
.
clientFactory
.
getLoadBalancerContext
(
serviceId
);
Server
server
=
new
Server
(
instance
.
getHost
(),
instance
.
getPort
());
boolean
secure
=
isSecure
(
server
,
serviceId
);
URI
uri
=
original
;
if
(
secure
)
{
uri
=
UriComponentsBuilder
.
fromUri
(
uri
).
scheme
(
"https"
).
build
().
toUri
();
}
IClientConfig
clientConfig
=
clientFactory
.
getClientConfig
(
serviceId
);
ServerIntrospector
serverIntrospector
=
serverIntrospector
(
serviceId
);
URI
uri
=
RibbonUtils
.
updateToHttpsIfNeeded
(
original
,
clientConfig
,
serverIntrospector
,
server
);
return
context
.
reconstructURIWithServer
(
server
,
uri
);
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
View file @
5a0af271
...
...
@@ -22,16 +22,14 @@ import java.io.OutputStream;
import
java.lang.reflect.Field
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Map.Entry
;
import
javax.servlet.ServletInputStream
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletRequestWrapper
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.Part
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.core.io.InputStreamResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.HttpEntity
;
...
...
@@ -44,6 +42,7 @@ import org.springframework.util.Assert;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartRequest
;
import
org.springframework.web.servlet.DispatcherServlet
;
...
...
@@ -65,7 +64,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
this
.
requestField
=
ReflectionUtils
.
findField
(
HttpServletRequestWrapper
.
class
,
"req"
,
HttpServletRequest
.
class
);
this
.
servletRequestField
=
ReflectionUtils
.
findField
(
ServletRequestWrapper
.
class
,
"request"
,
ServletRequest
.
class
);
"request"
,
ServletRequest
.
class
);
Assert
.
notNull
(
this
.
requestField
,
"HttpServletRequestWrapper.req field not found"
);
Assert
.
notNull
(
this
.
servletRequestField
,
...
...
@@ -121,7 +120,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
.
getField
(
this
.
requestField
,
request
);
wrapper
=
new
FormBodyRequestWrapper
(
wrapped
);
ReflectionUtils
.
setField
(
this
.
requestField
,
request
,
wrapper
);
if
(
request
instanceof
ServletRequestWrapper
)
{
if
(
request
instanceof
ServletRequestWrapper
)
{
ReflectionUtils
.
setField
(
this
.
servletRequestField
,
request
,
wrapper
);
}
}
...
...
@@ -170,7 +169,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
}
return
this
.
contentLength
;
}
@Override
public
long
getContentLengthLong
()
{
return
getContentLength
();
...
...
@@ -233,7 +232,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
Set
<
String
>
result
=
new
HashSet
<>();
String
query
=
this
.
request
.
getQueryString
();
if
(
query
!=
null
)
{
for
(
String
value
:
StringUtils
.
split
(
query
,
"&"
))
{
for
(
String
value
:
StringUtils
.
tokenizeToStringArray
(
query
,
"&"
))
{
if
(
value
.
contains
(
"="
))
{
value
=
value
.
substring
(
0
,
value
.
indexOf
(
"="
));
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClientTests.java
View file @
5a0af271
...
...
@@ -29,6 +29,7 @@ import org.mockito.MockitoAnnotations;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerRequest
;
import
org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.RibbonServer
;
import
org.springframework.web.util.DefaultUriTemplateHandler
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.IClientConfig
;
...
...
@@ -108,6 +109,31 @@ public class RibbonLoadBalancerClientTests {
}
@Test
public
void
testReconstructSecureUriWithSpecialCharsPath
()
{
testReconstructUriWithPath
(
"https"
,
"/foo=|"
);
}
@Test
public
void
testReconstructUnsecureUriWithSpecialCharsPath
()
{
testReconstructUriWithPath
(
"http"
,
"/foo=|"
);
}
private
void
testReconstructUriWithPath
(
String
scheme
,
String
path
)
{
RibbonServer
server
=
getRibbonServer
();
IClientConfig
config
=
mock
(
IClientConfig
.
class
);
when
(
config
.
get
(
CommonClientConfigKey
.
IsSecure
)).
thenReturn
(
true
);
when
(
clientFactory
.
getClientConfig
(
server
.
getServiceId
())).
thenReturn
(
config
);
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
ServiceInstance
serviceInstance
=
client
.
choose
(
server
.
getServiceId
());
URI
expanded
=
new
DefaultUriTemplateHandler
()
.
expand
(
scheme
+
"://"
+
server
.
getServiceId
()
+
path
);
URI
reconstructed
=
client
.
reconstructURI
(
serviceInstance
,
expanded
);
assertEquals
(
expanded
.
getPath
(),
reconstructed
.
getPath
());
}
@Test
@SneakyThrows
public
void
testReconstructUriWithSecureClientConfig
()
{
RibbonServer
server
=
getRibbonServer
();
...
...
spring-cloud-netflix-dependencies/pom.xml
View file @
5a0af271
...
...
@@ -17,7 +17,7 @@
<archaius.version>
0.7.4
</archaius.version>
<eureka.version>
1.4.11
</eureka.version>
<feign.version>
9.3.1
</feign.version>
<hystrix.version>
1.5.
5
</hystrix.version>
<hystrix.version>
1.5.
6
</hystrix.version>
<ribbon.version>
2.2.0
</ribbon.version>
<servo.version>
0.10.1
</servo.version>
<zuul.version>
1.2.2
</zuul.version>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment