Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feign can not handle ; correctly #1123

Closed
aftersss opened this issue Nov 29, 2019 · 1 comment · Fixed by #1138
Closed

Feign can not handle ; correctly #1123

aftersss opened this issue Nov 29, 2019 · 1 comment · Fixed by #1138
Assignees
Labels
bug Unexpected or incorrect behavior feedback provided Feedback has been provided to the author

Comments

@aftersss
Copy link

spring-cloud version: Greenwich.SR3
spring-boot-version: 2.1.9.RELEASE

I wrote the following feign interface:

@FeignClient(name = "test")
@RequestMapping("/test")
public interface RemoteService  {


    @RequestMapping(path="str", method = RequestMethod.POST)
    String str(@RequestParam("str") String str);

    @RequestMapping(path="list", method = RequestMethod.POST)
    List<String> list(@RequestParam("list") List<String> list);

}

@RestController
public class RemoteServiceImpl implements RemoteService   {
    public String str(String str){
        return str;
    }

    public List<String> list(List<String> list){
        return list;
    }
}

and then invoke it via feign like this:

Case 1 :

        String ret = remoteService.str("hello;world");
        //the expected output should be:`hello;world` , but actually I got:`hello,world`, 
        System.out.println(ret);

the expected output should be:hello;world , but actually I got:hello,world,

Case 2:

        List<String> list = new ArrayList<>();
        list.add("hello;world");
        String retList = remoteService.list(list);
        //the expected output should be:`["hello;world"]` , but actually I got:`["hello", "world"]`, 
        System.out.println(retList);

the expected output should be:["hello;world"] , but actually I got:["hello", "world"],

See also: spring-cloud/spring-cloud-openfeign#246

@kdavisk6 kdavisk6 added bug Unexpected or incorrect behavior feedback provided Feedback has been provided to the author labels Dec 2, 2019
@kdavisk6
Copy link
Member

kdavisk6 commented Dec 2, 2019

Hi @aftersss

Thank you for bringing this to our attention. This is a known issue related to our template handling. We are working on a fix for this, however; in the meantime, you will need to pct-encode the semi-colon ; as %3B wherever you need to use the character. This tell Feign to treat the value as a single value and not a list of values.

For more information on the underlying problem, see these other issues:

@kdavisk6 kdavisk6 self-assigned this Dec 26, 2019
kdavisk6 added a commit to kdavisk6/feign that referenced this issue Dec 26, 2019
Fixes OpenFeign#1123, Fixes OpenFeign#1133, Fixes OpenFeign#1102

Ensures that all expressions are fully-encoded before being
manipulated during template expansion.  This allows parameters
to include reserved values and result in properly encoded
results.

Additionally, `Iterable` values are now handled in accordance
with RFC 6570 allowing for the specified `CollectionFormat` to
be applied correctly.
kdavisk6 added a commit to kdavisk6/feign that referenced this issue Dec 26, 2019
Fixes OpenFeign#1123, Fixes OpenFeign#1133, Fixes OpenFeign#1102, Fixes OpenFeign#1028

Ensures that all expressions are fully-encoded before being
manipulated during template expansion.  This allows parameters
to include reserved values and result in properly encoded
results.

Additionally, `Iterable` values are now handled in accordance
with RFC 6570 allowing for the specified `CollectionFormat` to
be applied and empty parameters to be expanded correctly as this
is the main use case that exhibited this issue.
kdavisk6 added a commit to kdavisk6/feign that referenced this issue Dec 27, 2019
Fixes OpenFeign#1123, Fixes OpenFeign#1133, Fixes OpenFeign#1102, Fixes OpenFeign#1028

Ensures that all expressions are fully-encoded before being
manipulated during template expansion.  This allows parameters
to include reserved values and result in properly encoded
results.

Additionally, `Iterable` values are now handled in accordance
with RFC 6570 allowing for the specified `CollectionFormat` to
be applied and empty parameters to be expanded correctly as this
is the main use case that exhibited this issue.
kdavisk6 pushed a commit to kdavisk6/feign that referenced this issue Dec 27, 2019
kdavisk6 added a commit that referenced this issue Dec 27, 2019
* Ensure Iterable values are encoded before template expansion

Fixes #1123, Fixes #1133, Fixes #1102, Fixes #1028

Ensures that all expressions are fully-encoded before being
manipulated during template expansion.  This allows parameters
to include reserved values and result in properly encoded
results.

Additionally, `Iterable` values are now handled in accordance
with RFC 6570 allowing for the specified `CollectionFormat` to
be applied and empty parameters to be expanded correctly as this
is the main use case that exhibited this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior feedback provided Feedback has been provided to the author
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants