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
9f10d520
Commit
9f10d520
authored
Jun 09, 2017
by
André Dörnbrack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes a problem with whitespaces in list of retryable status codes
parent
484bde10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
RibbonLoadBalancedRetryPolicy.java
...k/cloud/netflix/ribbon/RibbonLoadBalancedRetryPolicy.java
+7
-7
RibbonLoadBalancedRetryPolicyFactoryTest.java
...flix/ribbon/RibbonLoadBalancedRetryPolicyFactoryTest.java
+3
-2
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancedRetryPolicy.java
View file @
9f10d520
...
...
@@ -18,17 +18,17 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.client.config.IClientConfigKey
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy
;
import
org.springframework.cloud.client.loadbalancer.ServiceInstanceChooser
;
import
org.springframework.core.env.Environment
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.util.StringUtils
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.client.config.IClientConfigKey
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* {@link LoadBalancedRetryPolicy} for Ribbon clients.
...
...
@@ -60,7 +60,7 @@ public class RibbonLoadBalancedRetryPolicy implements LoadBalancedRetryPolicy {
for
(
String
code
:
retryableStatusCodesArray
)
{
if
(!
StringUtils
.
isEmpty
(
code
))
{
try
{
retryableStatusCodes
.
add
(
Integer
.
valueOf
(
code
));
retryableStatusCodes
.
add
(
Integer
.
valueOf
(
code
.
trim
()
));
}
catch
(
NumberFormatException
e
)
{
//TODO log
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancedRetryPolicyFactoryTest.java
View file @
9f10d520
...
...
@@ -201,7 +201,7 @@ public class RibbonLoadBalancedRetryPolicyFactoryTest {
}
@Test
public
void
testRetryableStatusCodes
t
()
throws
Exception
{
public
void
testRetryableStatusCodes
()
throws
Exception
{
int
sameServer
=
3
;
int
nextServer
=
3
;
RibbonServer
server
=
getRibbonServer
();
...
...
@@ -210,7 +210,7 @@ public class RibbonLoadBalancedRetryPolicyFactoryTest {
doReturn
(
nextServer
).
when
(
config
).
get
(
eq
(
CommonClientConfigKey
.
MaxAutoRetriesNextServer
),
anyInt
());
doReturn
(
false
).
when
(
config
).
get
(
eq
(
CommonClientConfigKey
.
OkToRetryOnAllOperations
),
eq
(
false
));
doReturn
(
config
).
when
(
clientFactory
).
getClientConfig
(
eq
(
server
.
getServiceId
()));
doReturn
(
"404,502,foo, ,"
).
when
(
config
).
getPropertyAsString
(
eq
(
RibbonLoadBalancedRetryPolicy
.
RETRYABLE_STATUS_CODES
),
eq
(
""
));
doReturn
(
"404,502,
418,
foo, ,"
).
when
(
config
).
getPropertyAsString
(
eq
(
RibbonLoadBalancedRetryPolicy
.
RETRYABLE_STATUS_CODES
),
eq
(
""
));
clientFactory
.
getLoadBalancerContext
(
server
.
getServiceId
()).
setRetryHandler
(
new
DefaultLoadBalancerRetryHandler
(
config
));
RibbonLoadBalancerClient
client
=
getRibbonLoadBalancerClient
(
server
);
RibbonLoadBalancedRetryPolicyFactory
factory
=
new
RibbonLoadBalancedRetryPolicyFactory
(
clientFactory
);
...
...
@@ -220,6 +220,7 @@ public class RibbonLoadBalancedRetryPolicyFactoryTest {
assertThat
(
policy
.
retryableStatusCode
(
400
),
is
(
false
));
assertThat
(
policy
.
retryableStatusCode
(
404
),
is
(
true
));
assertThat
(
policy
.
retryableStatusCode
(
502
),
is
(
true
));
assertThat
(
policy
.
retryableStatusCode
(
418
),
is
(
true
));
}
protected
RibbonLoadBalancerClient
getRibbonLoadBalancerClient
(
...
...
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