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
a487d35f
Commit
a487d35f
authored
May 04, 2017
by
Ryan Baxter
Committed by
GitHub
May 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1910 from ryanjbaxter/feign-compression-config
Fix Feign Compression Config Order
parents
164ba013
15d4a719
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
4 deletions
+103
-4
FeignAcceptGzipEncodingAutoConfiguration.java
...gn/encoding/FeignAcceptGzipEncodingAutoConfiguration.java
+3
-2
FeignContentGzipEncodingAutoConfiguration.java
...n/encoding/FeignContentGzipEncodingAutoConfiguration.java
+3
-2
FeignCompressionTests.java
...gframework/cloud/netflix/feign/FeignCompressionTests.java
+97
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java
View file @
a487d35f
...
...
@@ -18,7 +18,8 @@ package org.springframework.cloud.netflix.feign.encoding;
import
feign.Feign
;
import
feign.httpclient.ApacheHttpClient
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
...
...
@@ -38,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnClass
(
Feign
.
class
)
@ConditionalOnBean
(
ApacheHttpClient
.
class
)
@ConditionalOnProperty
(
value
=
"feign.compression.response.enabled"
,
matchIfMissing
=
false
)
@AutoConfigure
Before
(
FeignAutoConfiguration
.
class
)
@AutoConfigure
After
(
FeignAutoConfiguration
.
class
)
public
class
FeignAcceptGzipEncodingAutoConfiguration
{
@Bean
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/encoding/FeignContentGzipEncodingAutoConfiguration.java
View file @
a487d35f
...
...
@@ -18,7 +18,8 @@ package org.springframework.cloud.netflix.feign.encoding;
import
feign.Feign
;
import
feign.httpclient.ApacheHttpClient
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
...
...
@@ -38,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnClass
(
Feign
.
class
)
@ConditionalOnBean
(
ApacheHttpClient
.
class
)
@ConditionalOnProperty
(
value
=
"feign.compression.request.enabled"
,
matchIfMissing
=
false
)
@AutoConfigure
Before
(
FeignAutoConfiguration
.
class
)
@AutoConfigure
After
(
FeignAutoConfiguration
.
class
)
public
class
FeignContentGzipEncodingAutoConfiguration
{
@Bean
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignCompressionTests.java
0 → 100644
View file @
a487d35f
/*
*
* * Copyright 2013-2017 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
;
import
feign.Client
;
import
feign.RequestInterceptor
;
import
feign.httpclient.ApacheHttpClient
;
import
java.util.Map
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.ClassPathExclusions
;
import
org.springframework.cloud.FilteredClassPathRunner
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.feign.encoding.FeignAcceptGzipEncodingAutoConfiguration
;
import
org.springframework.cloud.netflix.feign.encoding.FeignAcceptGzipEncodingInterceptor
;
import
org.springframework.cloud.netflix.feign.encoding.FeignContentGzipEncodingAutoConfiguration
;
import
org.springframework.cloud.netflix.feign.encoding.FeignContentGzipEncodingInterceptor
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* @author Ryan Baxter
*/
@RunWith
(
FilteredClassPathRunner
.
class
)
@ClassPathExclusions
({
"ribbon-loadbalancer-{version:\\d.*}.jar"
})
public
class
FeignCompressionTests
{
private
ConfigurableApplicationContext
context
;
@Before
public
void
setUp
()
{
context
=
new
SpringApplicationBuilder
().
properties
(
"feign.compression.response.enabled=true"
,
"feign.compression.request.enabled=true"
,
"feign.okhttp.enabled=false"
).
sources
(
PropertyPlaceholderAutoConfiguration
.
class
,
ArchaiusAutoConfiguration
.
class
,
FeignAutoConfiguration
.
class
,
PlainConfig
.
class
,
FeignContentGzipEncodingAutoConfiguration
.
class
,
FeignAcceptGzipEncodingAutoConfiguration
.
class
).
web
(
false
).
run
();
}
@After
public
void
tearDown
()
{
if
(
context
!=
null
)
{
context
.
close
();
}
}
@Test
public
void
testInterceptors
()
{
FeignContext
feignContext
=
context
.
getBean
(
FeignContext
.
class
);
Map
<
String
,
RequestInterceptor
>
interceptors
=
feignContext
.
getInstances
(
"foo"
,
RequestInterceptor
.
class
);
assertEquals
(
2
,
interceptors
.
size
());
assertTrue
(
FeignAcceptGzipEncodingInterceptor
.
class
.
isInstance
(
interceptors
.
get
(
"feignAcceptGzipEncodingInterceptor"
)));
assertTrue
(
FeignContentGzipEncodingInterceptor
.
class
.
isInstance
(
interceptors
.
get
(
"feignContentGzipEncodingInterceptor"
)));
}
@Configuration
protected
static
class
PlainConfig
{
@Autowired
private
Client
client
;
@Bean
public
ApacheHttpClient
client
()
{
/* We know our client is an AppacheHttpClient because we disabled the OK HTTP client. FeignAcceptGzipEncodingAutoConfiguration
* won't load unless there is a bean of type ApacheHttpClient (not Client) in this test because the bean is not
* yet created and so the application context doesnt know that the Client bean is actually an instance of ApacheHttpClient,
* therefore FeignAcceptGzipEncodingAutoConfiguration will not be loaded. We just create a bean here of type
* ApacheHttpClient so that the configuration will be loaded correctly.
*/
return
(
ApacheHttpClient
)
client
;
}
}
}
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