- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Julian Builes opened SPR-10046 and commented
When subclassing ResponseEntity that returns a JSON response, the body in the resulting response is also including 'headers' and 'statusCode fields.
        class MyClass {      
            public String field;            
            public MyClass(String field1) {
                this.field = field1;
            }
        }
        
        class MyClassResponse extends ResponseEntity<MyClass> {
            public MyClassResponse(MyClass body, HttpHeaders headers, HttpStatus statusCode) {
                super(body, headers, statusCode);
            }
        }
        
        @RequestMapping(value = "aaa", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
        @ResponseBody
        public ResponseEntity<MyClass> dummy() {
            HttpHeaders headers = new HttpHeaders();
            headers.add("some-header", "some header value");
            headers.add("another-header", "another header value");
            return new MyClassResponse(new MyClass("this is the response body"), headers, HttpStatus.CREATED);
        }
Is returning:
{
"headers": {
"some-header": [(1)
"some header value"
],-
"another-header": [(1)
"another header value"
]-
},-
"body": {
"field": "this is the response body"
},-
"statusCode": "CREATED"
}
Considerations:
- This appears to be a regression introduced between 3.1.2 and 3.1.3.
- We are using Jackson to convert the JSON
Affects: 3.1.3
1 votes, 4 watchers
Metadata
Metadata
Assignees
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid