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
8691a731
Commit
8691a731
authored
Feb 20, 2018
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/1.4.x'
parents
61bbca23
c35796af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
2 deletions
+159
-2
HttpClientFeignLoadBalancedConfiguration.java
...eign/ribbon/HttpClientFeignLoadBalancedConfiguration.java
+1
-1
OkHttpFeignLoadBalancedConfiguration.java
...ix/feign/ribbon/OkHttpFeignLoadBalancedConfiguration.java
+1
-1
FeignRibbonHttpClientConfigurationTests.java
...feign/ribbon/FeignRibbonHttpClientConfigurationTests.java
+87
-0
FeignRibbonOkHttpClientConfigurationTests.java
...ign/ribbon/FeignRibbonOkHttpClientConfigurationTests.java
+70
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/HttpClientFeignLoadBalancedConfiguration.java
View file @
8691a731
...
...
@@ -65,7 +65,7 @@ class HttpClientFeignLoadBalancedConfiguration {
ApacheHttpClientConnectionManagerFactory
connectionManagerFactory
,
FeignHttpClientProperties
httpClientProperties
)
{
final
HttpClientConnectionManager
connectionManager
=
connectionManagerFactory
.
newConnectionManager
(
false
,
httpClientProperties
.
getMaxConnections
(),
.
newConnectionManager
(
httpClientProperties
.
isDisableSslValidation
()
,
httpClientProperties
.
getMaxConnections
(),
httpClientProperties
.
getMaxConnectionsPerRoute
(),
httpClientProperties
.
getTimeToLive
(),
httpClientProperties
.
getTimeToLiveUnit
(),
registryBuilder
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/OkHttpFeignLoadBalancedConfiguration.java
View file @
8691a731
...
...
@@ -61,7 +61,7 @@ class OkHttpFeignLoadBalancedConfiguration {
ConnectionPool
connectionPool
,
FeignHttpClientProperties
httpClientProperties
)
{
Boolean
followRedirects
=
httpClientProperties
.
isFollowRedirects
();
Integer
connectTimeout
=
httpClientProperties
.
getConnectionTimeout
();
this
.
okHttpClient
=
httpClientFactory
.
createBuilder
(
false
).
this
.
okHttpClient
=
httpClientFactory
.
createBuilder
(
httpClientProperties
.
isDisableSslValidation
()
).
connectTimeout
(
connectTimeout
,
TimeUnit
.
MILLISECONDS
).
followRedirects
(
followRedirects
).
connectionPool
(
connectionPool
).
build
();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/ribbon/FeignRibbonHttpClientConfigurationTests.java
0 → 100644
View file @
8691a731
/*
* Copyright 2013-2018 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
.
feign
.
ribbon
;
import
java.lang.reflect.Field
;
import
javax.net.ssl.SSLContextSpi
;
import
javax.net.ssl.SSLSocketFactory
;
import
javax.net.ssl.X509TrustManager
;
import
org.apache.http.config.Lookup
;
import
org.apache.http.conn.HttpClientConnectionManager
;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
import
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.bind.annotation.RestController
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
/**
* @author Ryan Baxter
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
FeignRibbonHttpClientConfigurationTests
.
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
,
properties
=
{
"debug=true"
,
"feign.httpclient.disableSslValidation=true"
})
public
class
FeignRibbonHttpClientConfigurationTests
{
@Autowired
HttpClientConnectionManager
connectionManager
;
@Test
public
void
disableSslTest
()
throws
Exception
{
Lookup
<
ConnectionSocketFactory
>
socketFactoryRegistry
=
getConnectionSocketFactoryLookup
(
connectionManager
);
assertNotNull
(
socketFactoryRegistry
.
lookup
(
"https"
));
assertNull
(
this
.
getX509TrustManager
(
socketFactoryRegistry
).
getAcceptedIssuers
());
}
private
Lookup
<
ConnectionSocketFactory
>
getConnectionSocketFactoryLookup
(
HttpClientConnectionManager
connectionManager
)
{
DefaultHttpClientConnectionOperator
connectionOperator
=
(
DefaultHttpClientConnectionOperator
)
this
.
getField
(
connectionManager
,
"connectionOperator"
);
return
(
Lookup
)
this
.
getField
(
connectionOperator
,
"socketFactoryRegistry"
);
}
private
X509TrustManager
getX509TrustManager
(
Lookup
<
ConnectionSocketFactory
>
socketFactoryRegistry
)
{
ConnectionSocketFactory
connectionSocketFactory
=
(
ConnectionSocketFactory
)
socketFactoryRegistry
.
lookup
(
"https"
);
SSLSocketFactory
sslSocketFactory
=
(
SSLSocketFactory
)
this
.
getField
(
connectionSocketFactory
,
"socketfactory"
);
SSLContextSpi
sslContext
=
(
SSLContextSpi
)
this
.
getField
(
sslSocketFactory
,
"context"
);
return
(
X509TrustManager
)
this
.
getField
(
sslContext
,
"trustManager"
);
}
protected
<
T
>
Object
getField
(
Object
target
,
String
name
)
{
Field
field
=
ReflectionUtils
.
findField
(
target
.
getClass
(),
name
);
ReflectionUtils
.
makeAccessible
(
field
);
Object
value
=
ReflectionUtils
.
getField
(
field
,
target
);
return
value
;
}
@Configuration
@EnableAutoConfiguration
@RestController
public
static
class
Application
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
FeignRibbonClientRetryTests
.
Application
.
class
)
.
run
(
args
);
}
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/ribbon/FeignRibbonOkHttpClientConfigurationTests.java
0 → 100644
View file @
8691a731
/*
* Copyright 2013-2018 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
.
feign
.
ribbon
;
import
okhttp3.OkHttpClient
;
import
java.lang.reflect.Field
;
import
javax.net.ssl.HostnameVerifier
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.cloud.commons.httpclient.OkHttpClientFactory
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Ryan Baxter
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
FeignRibbonOkHttpClientConfigurationTests
.
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
,
properties
=
{
"debug=true"
,
"feign.httpclient.disableSslValidation=true"
,
"feign.okhttp.enabled=true"
,
"feign.httpclient.enabled=false"
})
public
class
FeignRibbonOkHttpClientConfigurationTests
{
@Autowired
OkHttpClient
httpClient
;
@Test
public
void
disableSslTest
()
throws
Exception
{
HostnameVerifier
hostnameVerifier
=
(
HostnameVerifier
)
this
.
getField
(
httpClient
,
"hostnameVerifier"
);
Assert
.
assertTrue
(
OkHttpClientFactory
.
TrustAllHostnames
.
class
.
isInstance
(
hostnameVerifier
));
}
protected
<
T
>
Object
getField
(
Object
target
,
String
name
)
{
Field
field
=
ReflectionUtils
.
findField
(
target
.
getClass
(),
name
);
ReflectionUtils
.
makeAccessible
(
field
);
Object
value
=
ReflectionUtils
.
getField
(
field
,
target
);
return
value
;
}
@Configuration
@EnableAutoConfiguration
@RestController
public
static
class
Application
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
FeignRibbonClientRetryTests
.
Application
.
class
)
.
run
(
args
);
}
}
}
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