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
a5bd17c0
Commit
a5bd17c0
authored
Jan 17, 2017
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove check that does not apply Formatters to Collection in Feign Client parameters. Fixes #1526
parent
a5e5f81d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
10 deletions
+30
-10
SpringMvcContract.java
...mework/cloud/netflix/feign/support/SpringMvcContract.java
+0
-8
SpringMvcContractTests.java
...k/cloud/netflix/feign/support/SpringMvcContractTests.java
+1
-1
FeignClientTests.java
...framework/cloud/netflix/feign/valid/FeignClientTests.java
+29
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java
View file @
a5bd17c0
...
@@ -241,7 +241,6 @@ public class SpringMvcContract extends Contract.BaseContract
...
@@ -241,7 +241,6 @@ public class SpringMvcContract extends Contract.BaseContract
}
}
}
}
if
(
isHttpAnnotation
&&
data
.
indexToExpander
().
get
(
paramIndex
)
==
null
if
(
isHttpAnnotation
&&
data
.
indexToExpander
().
get
(
paramIndex
)
==
null
&&
!
isMultiValued
(
method
.
getParameterTypes
()[
paramIndex
])
&&
this
.
conversionService
.
canConvert
(
&&
this
.
conversionService
.
canConvert
(
method
.
getParameterTypes
()[
paramIndex
],
String
.
class
))
{
method
.
getParameterTypes
()[
paramIndex
],
String
.
class
))
{
data
.
indexToExpander
().
put
(
paramIndex
,
this
.
expander
);
data
.
indexToExpander
().
put
(
paramIndex
,
this
.
expander
);
...
@@ -249,13 +248,6 @@ public class SpringMvcContract extends Contract.BaseContract
...
@@ -249,13 +248,6 @@ public class SpringMvcContract extends Contract.BaseContract
return
isHttpAnnotation
;
return
isHttpAnnotation
;
}
}
private
boolean
isMultiValued
(
Class
<?>
type
)
{
// Feign will deal with each element in a collection individually (with no
// expander as of 8.16.2, but we'd rather have no conversion than convert a
// collection to a String (which ends up being a csv).
return
Collection
.
class
.
isAssignableFrom
(
type
);
}
private
void
parseProduces
(
MethodMetadata
md
,
Method
method
,
private
void
parseProduces
(
MethodMetadata
md
,
Method
method
,
RequestMapping
annotation
)
{
RequestMapping
annotation
)
{
checkAtMostOne
(
method
,
annotation
.
produces
(),
"produces"
);
checkAtMostOne
(
method
,
annotation
.
produces
(),
"produces"
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/support/SpringMvcContractTests.java
View file @
a5bd17c0
...
@@ -294,7 +294,7 @@ public class SpringMvcContractTests {
...
@@ -294,7 +294,7 @@ public class SpringMvcContractTests {
assertEquals
(
"/test"
,
data
.
template
().
url
());
assertEquals
(
"/test"
,
data
.
template
().
url
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
"[{id}]"
,
data
.
template
().
queries
().
get
(
"id"
).
toString
());
assertEquals
(
"[{id}]"
,
data
.
template
().
queries
().
get
(
"id"
).
toString
());
assertNull
(
data
.
indexToExpander
().
get
(
0
));
assertN
otN
ull
(
data
.
indexToExpander
().
get
(
0
));
}
}
@Test
@Test
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/valid/FeignClientTests.java
View file @
a5bd17c0
...
@@ -29,6 +29,7 @@ import java.lang.reflect.Proxy;
...
@@ -29,6 +29,7 @@ import java.lang.reflect.Proxy;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
...
@@ -138,6 +139,11 @@ public class FeignClientTests {
...
@@ -138,6 +139,11 @@ public class FeignClientTests {
public
OtherArg
(
String
value
)
{
public
OtherArg
(
String
value
)
{
this
.
value
=
value
;
this
.
value
=
value
;
}
}
@Override
public
String
toString
()
{
return
value
;
}
}
}
@FeignClient
(
name
=
"localapp"
,
configuration
=
TestClientConfig
.
class
)
@FeignClient
(
name
=
"localapp"
,
configuration
=
TestClientConfig
.
class
)
...
@@ -186,6 +192,9 @@ public class FeignClientTests {
...
@@ -186,6 +192,9 @@ public class FeignClientTests {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/tostring2"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/tostring2"
)
String
getToString
(
@RequestParam
(
"arg"
)
OtherArg
arg
);
String
getToString
(
@RequestParam
(
"arg"
)
OtherArg
arg
);
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/tostringcollection"
)
Collection
<
String
>
getToString
(
@RequestParam
(
"arg"
)
Collection
<
OtherArg
>
args
);
}
}
public
static
class
TestClientConfig
{
public
static
class
TestClientConfig
{
...
@@ -325,6 +334,9 @@ public class FeignClientTests {
...
@@ -325,6 +334,9 @@ public class FeignClientTests {
@Override
@Override
public
String
print
(
OtherArg
object
,
Locale
locale
)
{
public
String
print
(
OtherArg
object
,
Locale
locale
)
{
if
(
"foo"
.
equals
(
object
.
value
))
{
return
"bar"
;
}
return
object
.
value
;
return
object
.
value
;
}
}
...
@@ -417,6 +429,15 @@ public class FeignClientTests {
...
@@ -417,6 +429,15 @@ public class FeignClientTests {
return
arg
.
value
;
return
arg
.
value
;
}
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/tostringcollection"
)
Collection
<
String
>
getToString
(
@RequestParam
(
"arg"
)
Collection
<
OtherArg
>
args
)
{
List
<
String
>
result
=
new
ArrayList
<>();
for
(
OtherArg
arg
:
args
)
{
result
.
add
(
arg
.
value
);
}
return
result
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
Application
.
class
)
new
SpringApplicationBuilder
(
Application
.
class
)
.
properties
(
"spring.application.name=feignclienttest"
,
.
properties
(
"spring.application.name=feignclienttest"
,
...
@@ -570,7 +591,14 @@ public class FeignClientTests {
...
@@ -570,7 +591,14 @@ public class FeignClientTests {
assertEquals
(
Arg
.
A
.
toString
(),
testClient
.
getToString
(
Arg
.
A
));
assertEquals
(
Arg
.
A
.
toString
(),
testClient
.
getToString
(
Arg
.
A
));
assertEquals
(
Arg
.
B
.
toString
(),
testClient
.
getToString
(
Arg
.
B
));
assertEquals
(
Arg
.
B
.
toString
(),
testClient
.
getToString
(
Arg
.
B
));
assertEquals
(
"foo"
,
testClient
.
getToString
(
new
OtherArg
(
"foo"
)));
assertEquals
(
"bar"
,
testClient
.
getToString
(
new
OtherArg
(
"foo"
)));
List
<
OtherArg
>
args
=
new
ArrayList
<>();
args
.
add
(
new
OtherArg
(
"foo"
));
args
.
add
(
new
OtherArg
(
"goo"
));
List
<
String
>
expectedResult
=
new
ArrayList
<>();
expectedResult
.
add
(
"bar"
);
expectedResult
.
add
(
"goo"
);
assertEquals
(
expectedResult
,
testClient
.
getToString
(
args
));
}
}
@Test
@Test
...
...
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