amadeus-java icon indicating copy to clipboard operation
amadeus-java copied to clipboard

Java string limit 64kb, longer than Trip Parser's input

Open tsolakoua opened this issue 5 years ago • 4 comments

Description

Tried to implemented support for Trip Parser #28. The string created for the POST can't be handled because it exceeds the 64kb limit and returns the error "constant string too long".

Steps to Reproduce

Switch to https://github.com/amadeus4dev/amadeus-java/pull/59 and run the following code by replacing the base64string with the actual base64 from the swagger. String body = "{\"data\":{\"type\":\"trip-parser-job\",\"content\":\"base64string\"}}"; TripParser tripParser = amadeus.travel.tripParserJobs.post(body);

Expected Behavior: Starts parsing job

Actual Behavior: constant string too long

tsolakoua avatar Mar 20 '20 10:03 tsolakoua

Hi @tsolakoua I can try helping out with this - pls let me know if its ok. Thank you.

chaudharydeepak avatar Mar 21 '20 03:03 chaudharydeepak

Hello @chaudharydeepak. Thank you so much for your interest in the issue. Definitely, feel free to have a look at it. At any point let us know if you need more information or anything that could be useful. To help you get started, make sure you went through the contributor's guide.

tsolakoua avatar Mar 23 '20 07:03 tsolakoua

Closed with https://github.com/amadeus4dev/amadeus-java/pull/104

tsolakoua avatar Nov 18 '21 14:11 tsolakoua

Hello, If the issue is still there I am suggesting to change the body field in the request to byte[] instead of String and create related method for String to be backward compatible. Like the below :

public class Request {
    private byte[] body;
    
    public byte[] getBody() {
        return body;
    }

    public void setBody(byte[] body) {
        this.body = body;
    }

    public String getBodyString() {
        return Arrays.toString(body);
    }

    public void setBodyString(String body) {
        this.body = body.getBytes(StandardCharsets.UTF_8);
    }
}

It seems that 64K limitation is not there for byte[] and if someone wants to send a really big body (more than 64K) then should use related setBody with byte[] input. Do you think this can help ?

_Hamid

1hamidreza avatar Nov 18 '21 17:11 1hamidreza