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
ac86e779
Commit
ac86e779
authored
Sep 14, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Feign ResponseEntity<Void> NPE
fixes gh-539
parent
13a3ea07
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
ResponseEntityDecoder.java
...rk/cloud/netflix/feign/support/ResponseEntityDecoder.java
+11
-4
SpringDecoderTests.java
...ringframework/cloud/netflix/feign/SpringDecoderTests.java
+19
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/ResponseEntityDecoder.java
View file @
ac86e779
...
...
@@ -39,8 +39,12 @@ public class ResponseEntityDecoder implements Decoder {
type
=
((
ParameterizedType
)
type
).
getActualTypeArguments
()[
0
];
Object
decodedObject
=
decoder
.
decode
(
response
,
type
);
Class
<?>
clazz
=
null
;
if
(
decodedObject
!=
null
)
{
clazz
=
decodedObject
.
getClass
();
}
return
createResponse
(
decodedObject
.
getClass
()
,
clazz
,
decodedObject
,
response
);
}
...
...
@@ -56,9 +60,11 @@ public class ResponseEntityDecoder implements Decoder {
headers
.
put
(
key
,
new
LinkedList
<>(
response
.
headers
().
get
(
key
)));
}
return
new
ResponseEntity
<
T
>(
clazz
.
cast
(
instance
),
headers
,
T
retVal
=
null
;
if
(
clazz
!=
null
&&
instance
!=
null
)
{
retVal
=
clazz
.
cast
(
instance
);
}
return
new
ResponseEntity
<>(
retVal
,
headers
,
HttpStatus
.
valueOf
(
response
.
status
()));
}
}
\ No newline at end of file
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/SpringDecoderTests.java
View file @
ac86e779
...
...
@@ -95,6 +95,17 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
assertEquals
(
"first hello didn't match"
,
"hello world 1"
,
hellos
.
get
(
0
));
}
@Test
public
void
testResponseEntityVoid
()
{
ResponseEntity
<
Void
>
response
=
testClient
().
getHelloVoid
();
assertNotNull
(
"response was null"
,
response
);
List
<
String
>
headers
=
response
.
getHeaders
().
get
(
"X-test-header"
);
assertNotNull
(
"headers was null"
,
headers
);
assertEquals
(
"headers size was wrong"
,
1
,
headers
.
size
());
String
header
=
headers
.
get
(
0
);
assertEquals
(
"header was wrong"
,
"myval"
,
header
);
}
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
@@ -114,6 +125,9 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hellostrings"
)
public
List
<
String
>
getHelloStrings
();
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hellovoid"
)
public
ResponseEntity
<
Void
>
getHelloVoid
();
}
@Configuration
...
...
@@ -127,6 +141,11 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
}
@Override
public
ResponseEntity
<
Void
>
getHelloVoid
()
{
return
ResponseEntity
.
noContent
().
header
(
"X-test-header"
,
"myval"
).
build
();
}
@Override
public
Hello
getHello
()
{
return
new
Hello
(
"hello world 1"
);
}
...
...
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