feign-form icon indicating copy to clipboard operation
feign-form copied to clipboard

Nested pojo & extending another POJO

Open seunghx opened this issue 5 years ago • 1 comments

public static class Temp {
    private String name;
    private int age;
    private List<String> list;
    private Nested nested;
    private Map<String, List<String>> map;

   public Temp(){}

    public Temp(String name, int age, List<String> list, Nested nested,
        Map<String, List<String>> map) {
      this.name = name;
      this.age = age;
      this.list = list;
      this.nested = nested;
      this.map = map;
    }
   // Getter, Setter toString ...
}
public class Nested {
  private String title;

  public Nested() {
  }
// Getter Setter etc ...
}

`

im testing feign for http client of my spring boot project

when i use api like below with POJO parameter typed Temp

@PostMapping(value = "/temp",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  String formEncodedPost(Temp temp);

It seemd that FormEncoder(accurately PojoUtil) just set Nested.toString() for 'title' property of Nested class

so when i log Nested instance

logger say "Nested{title='Nested{title='title 1'}"

this is debugging log for client side

 [POST /form HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: */*
User-Agent: Java/1.8.0_222
Host: localhost:8080
Connection: keep-alive
Content-Length: 77
name=tempName&list=1&list=2&list=3&nested=**Nested%7Btitle%3Dtitle+1%7D**&age=100]

and below is server side log ` Start processing with input [name=tempName&list=1&list=2&list=3&nested=Nested%7Btitle%3Dtitle+1%7D&age=100]

`

and nest Map or HashMap or LinkedMultiValueMap not works well. (server said, can not convert String to map)

this is bug? or intended action?

And maybe extending another pojo not works -> feign encode data to body only properties in child POJO

seunghx avatar Feb 19 '20 05:02 seunghx

can be connected with: #95

slawekjaranowski avatar Oct 09 '20 06:10 slawekjaranowski