ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.68k stars 753 forks source link

JSON stream coming from the wire get built, even if it is not used #4033

Closed SupunS closed 6 years ago

SupunS commented 7 years ago

Consider the below service:

import ballerina.net.http;

@http:configuration {basePath:"/echo"}
service<http> echo {

    @http:resourceConfig { methods:["POST"], path:"/" }
    resource echo (http:Request req, http:Response res) {
        json payload = req.getJsonPayload();

        res.setStringPayload("hello!");
        res.send();
    }
}

Here at the implementation level, the stream coming from the wire do get built at the point the payload is retrieved as JSON. i.e: req.getJsonPayload();.

But ideally since the payload json is never used, it should not get built.

SupunS commented 6 years ago

We had several discussions regarding this, and concluded that this is the expected behavior.