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
c3f56788
Commit
c3f56788
authored
Apr 30, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only invoke RestClient.initWithNiwsConfig once
fixes gh-324
parent
5166994f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
3 deletions
+63
-3
RibbonClientConfiguration.java
...ework/cloud/netflix/ribbon/RibbonClientConfiguration.java
+4
-3
RibbonClientConfigurationTests.java
.../cloud/netflix/ribbon/RibbonClientConfigurationTests.java
+59
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClientConfiguration.java
View file @
c3f56788
...
...
@@ -123,10 +123,11 @@ public class RibbonClientConfiguration {
return
new
RibbonLoadBalancerContext
(
loadBalancer
,
config
);
}
private
static
class
OverrideRestClient
extends
RestClient
{
static
class
OverrideRestClient
extends
RestClient
{
private
OverrideRestClient
(
IClientConfig
ncc
)
{
super
(
ncc
);
protected
OverrideRestClient
(
IClientConfig
ncc
)
{
super
();
initWithNiwsConfig
(
ncc
);
}
@Override
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientConfigurationTests.java
0 → 100644
View file @
c3f56788
/*
* Copyright 2013-2015 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
*
* http://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
.
ribbon
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.DefaultClientConfigImpl
;
import
com.netflix.client.config.IClientConfig
;
import
org.junit.Test
;
/**
* @author Spencer Gibb
*/
public
class
RibbonClientConfigurationTests
{
@Test
public
void
restClientInitCalledOnce
()
{
CountingConfig
config
=
new
CountingConfig
();
config
.
setProperty
(
CommonClientConfigKey
.
ConnectTimeout
,
"1"
);
config
.
setProperty
(
CommonClientConfigKey
.
ReadTimeout
,
"1"
);
config
.
setProperty
(
CommonClientConfigKey
.
MaxHttpConnectionsPerHost
,
"1"
);
config
.
setClientName
(
"testClient"
);
new
TestRestClient
(
config
);
assertThat
(
config
.
count
,
is
(
equalTo
(
1
)));
}
static
class
CountingConfig
extends
DefaultClientConfigImpl
{
int
count
=
0
;
}
static
class
TestRestClient
extends
RibbonClientConfiguration
.
OverrideRestClient
{
private
TestRestClient
(
IClientConfig
ncc
)
{
super
(
ncc
);
}
@Override
public
void
initWithNiwsConfig
(
IClientConfig
clientConfig
)
{
((
CountingConfig
)
clientConfig
).
count
++;
super
.
initWithNiwsConfig
(
clientConfig
);
}
}
}
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