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
3bfc90a8
Unverified
Commit
3bfc90a8
authored
Jun 08, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 2.0.x
parents
52ee7c87
15295dd2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
5 deletions
+33
-5
ArchaiusAutoConfiguration.java
...ork/cloud/netflix/archaius/ArchaiusAutoConfiguration.java
+3
-0
RetryableFeignLoadBalancer.java
...loud/netflix/feign/ribbon/RetryableFeignLoadBalancer.java
+1
-0
RetryableRibbonLoadBalancingHttpClient.java
...ribbon/apache/RetryableRibbonLoadBalancingHttpClient.java
+4
-0
RetryableOkHttpLoadBalancingClient.java
...lix/ribbon/okhttp/RetryableOkHttpLoadBalancingClient.java
+1
-0
SendErrorFilter.java
...work/cloud/netflix/zuul/filters/post/SendErrorFilter.java
+1
-0
RibbonLoadBalancingHttpClientTests.java
...lix/ribbon/apache/RibbonLoadBalancingHttpClientTests.java
+7
-3
SendErrorFilterTests.java
...cloud/netflix/zuul/filters/post/SendErrorFilterTests.java
+14
-0
pom.xml
spring-cloud-netflix-dependencies/pom.xml
+2
-2
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/archaius/ArchaiusAutoConfiguration.java
View file @
3bfc90a8
...
@@ -33,6 +33,7 @@ import org.apache.commons.configuration.event.ConfigurationListener;
...
@@ -33,6 +33,7 @@ import org.apache.commons.configuration.event.ConfigurationListener;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint
;
import
org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.autoconfigure.AutoConfigureOrder
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
...
@@ -40,6 +41,7 @@ import org.springframework.context.ApplicationContext;
...
@@ -40,6 +41,7 @@ import org.springframework.context.ApplicationContext;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
...
@@ -68,6 +70,7 @@ import lombok.extern.apachecommons.CommonsLog;
...
@@ -68,6 +70,7 @@ import lombok.extern.apachecommons.CommonsLog;
@ConditionalOnClass
({
ConcurrentCompositeConfiguration
.
class
,
@ConditionalOnClass
({
ConcurrentCompositeConfiguration
.
class
,
ConfigurationBuilder
.
class
})
ConfigurationBuilder
.
class
})
@CommonsLog
@CommonsLog
@AutoConfigureOrder
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
ArchaiusAutoConfiguration
{
public
class
ArchaiusAutoConfiguration
{
private
static
final
AtomicBoolean
initialized
=
new
AtomicBoolean
(
false
);
private
static
final
AtomicBoolean
initialized
=
new
AtomicBoolean
(
false
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/RetryableFeignLoadBalancer.java
View file @
3bfc90a8
...
@@ -91,6 +91,7 @@ public class RetryableFeignLoadBalancer extends FeignLoadBalancer implements Ser
...
@@ -91,6 +91,7 @@ public class RetryableFeignLoadBalancer extends FeignLoadBalancer implements Ser
}
}
Response
response
=
request
.
client
().
execute
(
feignRequest
,
options
);
Response
response
=
request
.
client
().
execute
(
feignRequest
,
options
);
if
(
retryPolicy
.
retryableStatusCode
(
response
.
status
()))
{
if
(
retryPolicy
.
retryableStatusCode
(
response
.
status
()))
{
response
.
close
();
throw
new
RetryableStatusCodeException
(
RetryableFeignLoadBalancer
.
this
.
getClientName
(),
response
.
status
());
throw
new
RetryableStatusCodeException
(
RetryableFeignLoadBalancer
.
this
.
getClientName
(),
response
.
status
());
}
}
return
new
RibbonResponse
(
request
.
getUri
(),
response
);
return
new
RibbonResponse
(
request
.
getUri
(),
response
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/apache/RetryableRibbonLoadBalancingHttpClient.java
View file @
3bfc90a8
...
@@ -20,6 +20,7 @@ import java.net.URI;
...
@@ -20,6 +20,7 @@ import java.net.URI;
import
org.apache.commons.lang.BooleanUtils
;
import
org.apache.commons.lang.BooleanUtils
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext
;
...
@@ -91,6 +92,9 @@ public class RetryableRibbonLoadBalancingHttpClient extends RibbonLoadBalancingH
...
@@ -91,6 +92,9 @@ public class RetryableRibbonLoadBalancingHttpClient extends RibbonLoadBalancingH
HttpUriRequest
httpUriRequest
=
newRequest
.
toRequest
(
requestConfig
);
HttpUriRequest
httpUriRequest
=
newRequest
.
toRequest
(
requestConfig
);
final
HttpResponse
httpResponse
=
RetryableRibbonLoadBalancingHttpClient
.
this
.
delegate
.
execute
(
httpUriRequest
);
final
HttpResponse
httpResponse
=
RetryableRibbonLoadBalancingHttpClient
.
this
.
delegate
.
execute
(
httpUriRequest
);
if
(
retryPolicy
.
retryableStatusCode
(
httpResponse
.
getStatusLine
().
getStatusCode
()))
{
if
(
retryPolicy
.
retryableStatusCode
(
httpResponse
.
getStatusLine
().
getStatusCode
()))
{
if
(
CloseableHttpResponse
.
class
.
isInstance
(
httpResponse
))
{
((
CloseableHttpResponse
)
httpResponse
).
close
();
}
throw
new
RetryableStatusCodeException
(
RetryableRibbonLoadBalancingHttpClient
.
this
.
clientName
,
throw
new
RetryableStatusCodeException
(
RetryableRibbonLoadBalancingHttpClient
.
this
.
clientName
,
httpResponse
.
getStatusLine
().
getStatusCode
());
httpResponse
.
getStatusLine
().
getStatusCode
());
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/okhttp/RetryableOkHttpLoadBalancingClient.java
View file @
3bfc90a8
...
@@ -96,6 +96,7 @@ public class RetryableOkHttpLoadBalancingClient extends OkHttpLoadBalancingClien
...
@@ -96,6 +96,7 @@ public class RetryableOkHttpLoadBalancingClient extends OkHttpLoadBalancingClien
final
Request
request
=
newRequest
.
toRequest
();
final
Request
request
=
newRequest
.
toRequest
();
Response
response
=
httpClient
.
newCall
(
request
).
execute
();
Response
response
=
httpClient
.
newCall
(
request
).
execute
();
if
(
retryPolicy
.
retryableStatusCode
(
response
.
code
()))
{
if
(
retryPolicy
.
retryableStatusCode
(
response
.
code
()))
{
response
.
close
();
throw
new
RetryableStatusCodeException
(
RetryableOkHttpLoadBalancingClient
.
this
.
clientName
,
response
.
code
());
throw
new
RetryableStatusCodeException
(
RetryableOkHttpLoadBalancingClient
.
this
.
clientName
,
response
.
code
());
}
}
return
new
OkHttpRibbonResponse
(
response
,
newRequest
.
getUri
());
return
new
OkHttpRibbonResponse
(
response
,
newRequest
.
getUri
());
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendErrorFilter.java
View file @
3bfc90a8
...
@@ -87,6 +87,7 @@ public class SendErrorFilter extends ZuulFilter {
...
@@ -87,6 +87,7 @@ public class SendErrorFilter extends ZuulFilter {
if
(
dispatcher
!=
null
)
{
if
(
dispatcher
!=
null
)
{
ctx
.
set
(
SEND_ERROR_FILTER_RAN
,
true
);
ctx
.
set
(
SEND_ERROR_FILTER_RAN
,
true
);
if
(!
ctx
.
getResponse
().
isCommitted
())
{
if
(!
ctx
.
getResponse
().
isCommitted
())
{
ctx
.
setResponseStatusCode
(
exception
.
nStatusCode
);
dispatcher
.
forward
(
request
,
ctx
.
getResponse
());
dispatcher
.
forward
(
request
,
ctx
.
getResponse
());
}
}
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/apache/RibbonLoadBalancingHttpClientTests.java
View file @
3bfc90a8
...
@@ -23,6 +23,7 @@ import org.apache.http.HttpResponse;
...
@@ -23,6 +23,7 @@ import org.apache.http.HttpResponse;
import
org.apache.http.StatusLine
;
import
org.apache.http.StatusLine
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -288,7 +289,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -288,7 +289,7 @@ public class RibbonLoadBalancingHttpClientTests {
HttpMethod
method
=
HttpMethod
.
POST
;
HttpMethod
method
=
HttpMethod
.
POST
;
URI
uri
=
new
URI
(
"http://"
+
host
+
":"
+
port
);
URI
uri
=
new
URI
(
"http://"
+
host
+
":"
+
port
);
HttpClient
delegate
=
mock
(
HttpClient
.
class
);
HttpClient
delegate
=
mock
(
HttpClient
.
class
);
final
HttpResponse
response
=
mock
(
HttpResponse
.
class
);
final
CloseableHttpResponse
response
=
mock
(
Closeable
HttpResponse
.
class
);
StatusLine
statusLine
=
mock
(
StatusLine
.
class
);
StatusLine
statusLine
=
mock
(
StatusLine
.
class
);
doReturn
(
200
).
when
(
statusLine
).
getStatusCode
();
doReturn
(
200
).
when
(
statusLine
).
getStatusCode
();
doReturn
(
statusLine
).
when
(
response
).
getStatusLine
();
doReturn
(
statusLine
).
when
(
response
).
getStatusLine
();
...
@@ -304,6 +305,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -304,6 +305,7 @@ public class RibbonLoadBalancingHttpClientTests {
HttpUriRequest
uriRequest
=
mock
(
HttpUriRequest
.
class
);
HttpUriRequest
uriRequest
=
mock
(
HttpUriRequest
.
class
);
doReturn
(
uriRequest
).
when
(
request
).
toRequest
(
any
(
RequestConfig
.
class
));
doReturn
(
uriRequest
).
when
(
request
).
toRequest
(
any
(
RequestConfig
.
class
));
RibbonApacheHttpResponse
returnedResponse
=
client
.
execute
(
request
,
null
);
RibbonApacheHttpResponse
returnedResponse
=
client
.
execute
(
request
,
null
);
verify
(
response
,
times
(
0
)).
close
();
verify
(
delegate
,
times
(
3
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
delegate
,
times
(
3
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
lb
,
times
(
1
)).
chooseServer
(
eq
(
serviceName
));
verify
(
lb
,
times
(
1
)).
chooseServer
(
eq
(
serviceName
));
}
}
...
@@ -320,7 +322,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -320,7 +322,7 @@ public class RibbonLoadBalancingHttpClientTests {
HttpMethod
method
=
HttpMethod
.
POST
;
HttpMethod
method
=
HttpMethod
.
POST
;
URI
uri
=
new
URI
(
"http://"
+
host
+
":"
+
port
);
URI
uri
=
new
URI
(
"http://"
+
host
+
":"
+
port
);
HttpClient
delegate
=
mock
(
HttpClient
.
class
);
HttpClient
delegate
=
mock
(
HttpClient
.
class
);
final
HttpResponse
response
=
mock
(
HttpResponse
.
class
);
final
CloseableHttpResponse
response
=
mock
(
Closeable
HttpResponse
.
class
);
doThrow
(
new
IOException
(
"boom"
)).
doThrow
(
new
IOException
(
"boom again"
)).
doReturn
(
response
).
doThrow
(
new
IOException
(
"boom"
)).
doThrow
(
new
IOException
(
"boom again"
)).
doReturn
(
response
).
when
(
delegate
).
execute
(
any
(
HttpUriRequest
.
class
));
when
(
delegate
).
execute
(
any
(
HttpUriRequest
.
class
));
ILoadBalancer
lb
=
mock
(
ILoadBalancer
.
class
);
ILoadBalancer
lb
=
mock
(
ILoadBalancer
.
class
);
...
@@ -337,6 +339,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -337,6 +339,7 @@ public class RibbonLoadBalancingHttpClientTests {
client
.
execute
(
request
,
null
);
client
.
execute
(
request
,
null
);
fail
(
"Expected IOException"
);
fail
(
"Expected IOException"
);
}
catch
(
IOException
e
)
{}
finally
{
}
catch
(
IOException
e
)
{}
finally
{
verify
(
response
,
times
(
0
)).
close
();
verify
(
delegate
,
times
(
1
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
delegate
,
times
(
1
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
lb
,
times
(
0
)).
chooseServer
(
eq
(
serviceName
));
verify
(
lb
,
times
(
0
)).
chooseServer
(
eq
(
serviceName
));
}
}
...
@@ -358,7 +361,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -358,7 +361,7 @@ public class RibbonLoadBalancingHttpClientTests {
StatusLine
statusLine
=
mock
(
StatusLine
.
class
);
StatusLine
statusLine
=
mock
(
StatusLine
.
class
);
doReturn
(
200
).
when
(
statusLine
).
getStatusCode
();
doReturn
(
200
).
when
(
statusLine
).
getStatusCode
();
doReturn
(
statusLine
).
when
(
response
).
getStatusLine
();
doReturn
(
statusLine
).
when
(
response
).
getStatusLine
();
final
HttpResponse
fourOFourResponse
=
mock
(
HttpResponse
.
class
);
final
CloseableHttpResponse
fourOFourResponse
=
mock
(
Closeable
HttpResponse
.
class
);
StatusLine
fourOFourStatusLine
=
mock
(
StatusLine
.
class
);
StatusLine
fourOFourStatusLine
=
mock
(
StatusLine
.
class
);
doReturn
(
404
).
when
(
fourOFourStatusLine
).
getStatusCode
();
doReturn
(
404
).
when
(
fourOFourStatusLine
).
getStatusCode
();
doReturn
(
fourOFourStatusLine
).
when
(
fourOFourResponse
).
getStatusLine
();
doReturn
(
fourOFourStatusLine
).
when
(
fourOFourResponse
).
getStatusLine
();
...
@@ -374,6 +377,7 @@ public class RibbonLoadBalancingHttpClientTests {
...
@@ -374,6 +377,7 @@ public class RibbonLoadBalancingHttpClientTests {
doReturn
(
uri
).
when
(
uriRequest
).
getURI
();
doReturn
(
uri
).
when
(
uriRequest
).
getURI
();
doReturn
(
uriRequest
).
when
(
request
).
toRequest
(
any
(
RequestConfig
.
class
));
doReturn
(
uriRequest
).
when
(
request
).
toRequest
(
any
(
RequestConfig
.
class
));
RibbonApacheHttpResponse
returnedResponse
=
client
.
execute
(
request
,
null
);
RibbonApacheHttpResponse
returnedResponse
=
client
.
execute
(
request
,
null
);
verify
(
fourOFourResponse
,
times
(
1
)).
close
();
verify
(
delegate
,
times
(
2
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
delegate
,
times
(
2
)).
execute
(
any
(
HttpUriRequest
.
class
));
verify
(
lb
,
times
(
0
)).
chooseServer
(
eq
(
serviceName
));
verify
(
lb
,
times
(
0
)).
chooseServer
(
eq
(
serviceName
));
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/post/SendErrorFilterTests.java
View file @
3bfc90a8
...
@@ -29,6 +29,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
...
@@ -29,6 +29,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
@@ -82,4 +83,17 @@ public class SendErrorFilterTests {
...
@@ -82,4 +83,17 @@ public class SendErrorFilterTests {
filter
.
run
();
filter
.
run
();
assertFalse
(
"shouldFilter returned true"
,
filter
.
shouldFilter
());
assertFalse
(
"shouldFilter returned true"
,
filter
.
shouldFilter
());
}
}
@Test
public
void
setResponseCode
()
{
SendErrorFilter
filter
=
createSendErrorFilter
(
new
MockHttpServletRequest
());
filter
.
run
();
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
int
resCode
=
ctx
.
getResponse
().
getStatus
();
int
ctxCode
=
ctx
.
getResponseStatusCode
();
assertEquals
(
"invalid response code: "
+
resCode
,
HttpStatus
.
NOT_FOUND
.
value
(),
resCode
);
assertEquals
(
"invalid response code in RequestContext: "
+
ctxCode
,
resCode
,
ctxCode
);
}
}
}
spring-cloud-netflix-dependencies/pom.xml
View file @
3bfc90a8
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
<name>
spring-cloud-netflix-dependencies
</name>
<name>
spring-cloud-netflix-dependencies
</name>
<description>
Spring Cloud Netflix Dependencies
</description>
<description>
Spring Cloud Netflix Dependencies
</description>
<properties>
<properties>
<archaius.version>
0.7.
4
</archaius.version>
<archaius.version>
0.7.
5
</archaius.version>
<eureka.version>
1.
6.2
</eureka.version>
<eureka.version>
1.
7.0
</eureka.version>
<feign.version>
9.5.0
</feign.version>
<feign.version>
9.5.0
</feign.version>
<hystrix.version>
1.5.12
</hystrix.version>
<hystrix.version>
1.5.12
</hystrix.version>
<ribbon.version>
2.2.2
</ribbon.version>
<ribbon.version>
2.2.2
</ribbon.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