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
91808bb0
Unverified
Commit
91808bb0
authored
Sep 28, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for feign OptionalDecoder
fixes gh-1982
parent
25337dd4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
18 deletions
+56
-18
pom.xml
spring-cloud-netflix-core/pom.xml
+5
-0
FeignClientsConfiguration.java
...mework/cloud/netflix/feign/FeignClientsConfiguration.java
+2
-1
EnableFeignClientsTests.java
...ramework/cloud/netflix/feign/EnableFeignClientsTests.java
+2
-2
FeignClientOverrideDefaultsTests.java
...cloud/netflix/feign/FeignClientOverrideDefaultsTests.java
+6
-6
FeignClientTests.java
...framework/cloud/netflix/feign/valid/FeignClientTests.java
+31
-8
pom.xml
spring-cloud-netflix-dependencies/pom.xml
+6
-1
pom.xml
...ud-starter-netflix/spring-cloud-starter-openfeign/pom.xml
+4
-0
No files found.
spring-cloud-netflix-core/pom.xml
View file @
91808bb0
...
...
@@ -115,6 +115,11 @@
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-java8
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.netflix.hystrix
</groupId>
<artifactId>
hystrix-core
</artifactId>
<optional>
true
</optional>
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsConfiguration.java
View file @
91808bb0
...
...
@@ -46,6 +46,7 @@ import feign.Retryer;
import
feign.codec.Decoder
;
import
feign.codec.Encoder
;
import
feign.hystrix.HystrixFeign
;
import
feign.optionals.OptionalDecoder
;
/**
* @author Dave Syer
...
...
@@ -69,7 +70,7 @@ public class FeignClientsConfiguration {
@Bean
@ConditionalOnMissingBean
public
Decoder
feignDecoder
()
{
return
new
ResponseEntityDecoder
(
new
SpringDecoder
(
this
.
messageConverters
));
return
new
OptionalDecoder
(
new
ResponseEntityDecoder
(
new
SpringDecoder
(
this
.
messageConverters
)
));
}
@Bean
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/EnableFeignClientsTests.java
View file @
91808bb0
...
...
@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder
;
import
org.springframework.cloud.netflix.feign.support.SpringEncoder
;
import
org.springframework.cloud.netflix.feign.support.SpringMvcContract
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -36,6 +35,7 @@ import feign.Feign;
import
feign.Logger
;
import
feign.codec.Decoder
;
import
feign.codec.Encoder
;
import
feign.optionals.OptionalDecoder
;
import
feign.slf4j.Slf4jLogger
;
/**
...
...
@@ -51,7 +51,7 @@ public class EnableFeignClientsTests {
@Test
public
void
decoderDefaultCorrect
()
{
ResponseEntity
Decoder
.
class
Optional
Decoder
.
class
.
cast
(
this
.
feignContext
.
getInstance
(
"foo"
,
Decoder
.
class
));
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignClientOverrideDefaultsTests.java
View file @
91808bb0
...
...
@@ -17,17 +17,12 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration
;
import
org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder
;
import
org.springframework.cloud.netflix.feign.support.SpringEncoder
;
import
org.springframework.cloud.netflix.feign.support.SpringMvcContract
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -38,6 +33,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
feign.Contract
;
import
feign.Feign
;
import
feign.Logger
;
...
...
@@ -51,6 +50,7 @@ import feign.codec.Decoder;
import
feign.codec.Encoder
;
import
feign.codec.ErrorDecoder
;
import
feign.hystrix.HystrixFeign
;
import
feign.optionals.OptionalDecoder
;
import
feign.slf4j.Slf4jLogger
;
/**
...
...
@@ -79,7 +79,7 @@ public class FeignClientOverrideDefaultsTests {
@Test
public
void
overrideDecoder
()
{
Decoder
.
Default
.
class
.
cast
(
this
.
context
.
getInstance
(
"foo"
,
Decoder
.
class
));
ResponseEntity
Decoder
.
class
.
cast
(
this
.
context
.
getInstance
(
"bar"
,
Decoder
.
class
));
Optional
Decoder
.
class
.
cast
(
this
.
context
.
getInstance
(
"bar"
,
Decoder
.
class
));
}
@Test
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/valid/FeignClientTests.java
View file @
91808bb0
...
...
@@ -16,14 +16,6 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
.
valid
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
...
...
@@ -34,6 +26,7 @@ import java.util.Collection;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -76,6 +69,15 @@ import com.netflix.hystrix.HystrixCommandKey;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
feign.Client
;
import
feign.Feign
;
import
feign.Logger
;
...
...
@@ -161,6 +163,9 @@ public class FeignClientTests {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/hello"
)
Hello
getHello
();
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/hello"
)
Optional
<
Hello
>
getOptionalHello
();
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"${feignClient.methodLevelRequestMappingPath}"
)
Hello
getHelloUsingPropertyPlaceHolder
();
...
...
@@ -240,6 +245,9 @@ public class FeignClientTests {
protected
interface
DecodingTestClient
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/notFound"
)
ResponseEntity
<
String
>
notFound
();
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/notFound"
)
Optional
<
String
>
optional
();
}
@FeignClient
(
name
=
"localapp3"
,
fallback
=
HystrixClientFallback
.
class
)
...
...
@@ -519,6 +527,15 @@ public class FeignClientTests {
}
@Test
public
void
testOptional
()
{
Optional
<
Hello
>
hello
=
this
.
testClient
.
getOptionalHello
();
assertThat
(
hello
)
.
isNotNull
()
.
isPresent
()
.
contains
(
new
Hello
(
HELLO_WORLD_1
));
}
@Test
public
void
testGenericType
()
{
List
<
Hello
>
hellos
=
this
.
testClient
.
getHellos
();
assertNotNull
(
"hellos was null"
,
hellos
);
...
...
@@ -633,6 +650,12 @@ public class FeignClientTests {
}
@Test
public
void
testOptionalNotFound
()
{
Optional
<
String
>
s
=
decodingTestClient
.
optional
();
assertThat
(
s
).
isNotPresent
();
}
@Test
public
void
testConvertingExpander
()
{
assertEquals
(
Arg
.
A
.
toString
(),
testClient
.
getToString
(
Arg
.
A
));
assertEquals
(
Arg
.
B
.
toString
(),
testClient
.
getToString
(
Arg
.
B
));
...
...
spring-cloud-netflix-dependencies/pom.xml
View file @
91808bb0
...
...
@@ -16,7 +16,7 @@
<properties>
<archaius.version>
0.7.5
</archaius.version>
<eureka.version>
1.8.2
</eureka.version>
<feign.version>
9.5.
0
</feign.version>
<feign.version>
9.5.
1
</feign.version>
<hystrix.version>
1.5.12
</hystrix.version>
<ribbon.version>
2.2.2
</ribbon.version>
<servo.version>
0.10.1
</servo.version>
...
...
@@ -283,6 +283,11 @@
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-java8
</artifactId>
<version>
${feign.version}
</version>
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-okhttp
</artifactId>
<version>
${feign.version}
</version>
</dependency>
...
...
spring-cloud-starter-netflix/spring-cloud-starter-openfeign/pom.xml
View file @
91808bb0
...
...
@@ -47,6 +47,10 @@
<artifactId>
feign-hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-java8
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-ribbon
</artifactId>
</dependency>
...
...
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