Affects: \5.2.2


I am not sure if this is the correct repository (maybe Websocket?), but i found a different behavior in JSON deserialization in Websocket-Endpoints and Mvc-Endpoints.
While Mvc-Endpoints require setter to parse data correctly, this is not the case for Websocket-Endpoints.

of cause this is not a bug, but more an feature-request/improvement.

For me, i would prefer the Jackson-Config as used in Websocket (not to be forced to use setters), but at least, wouldnt it be better to use the same config for both (as long as one is not explicitly customized)?

Here is a small example:

@Controller
public class Test {

    @PostMapping("/api/data-test")
    public void getDataByPost(DataRequest request, HttpSession session) {
        System.out.println(request.dataId); // Without setter the value is 0, with setter the correct value is available
    }

    @MessageMapping("/api/data-test")
    public void getData(DataRequest request, SimpMessageHeaderAccessor headerAccessor) {
        System.out.println(request.dataId); // correct value is available  (as long the attribute is public)
    }

    public static class DataRequest {
        public int dataId;
        // public int getDataId() { return dataId; }
        // public void setDataId(int dataId) { this.dataId = dataId; }
    }
}

Comment From: bclozel

Could you provide a sample application we could run? How are you sending data to the server? Are you getting an error message?

Comment From: sunchezz89

@bclozel I will try to find some time for this, sure. I'll keep you informed.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.