sdl_java_suite icon indicating copy to clipboard operation
sdl_java_suite copied to clipboard

Protocol message sets JSON size to 0

Open mikeburke106 opened this issue 10 years ago • 4 comments

From ProtocolMessage.java.

    public void setData(byte[] data, int length) {
        if (this._data != null)
            this._data = null;
        this._data = new byte[length];
        System.arraycopy(data, 0, this._data, 0, length);
        this._jsonSize = 0;
    }

JSON size should be set to length, not 0.

mikeburke106 avatar Feb 25 '15 16:02 mikeburke106

setData is only used when there only a protocol header and binary data. JSON size is in the binary header, which won't exist if this method is being called.

khburdette avatar Feb 26 '15 18:02 khburdette

If that's the case, why is there a polymorphic method directly above it, which sets the JSON size to the size of the data array?

    public void setData(byte[] data) {
        this._data = data;
        this._jsonSize = data.length;
    }

If these methods are for different purposes, they should have different names.

mikeburke106 avatar Feb 26 '15 19:02 mikeburke106

I would be ok with different names

khburdette avatar Feb 26 '15 19:02 khburdette

So, when someone calls getData, how do they know if the returned data is purely JSON in binary format vs. the header info?

mikeburke106 avatar Feb 26 '15 19:02 mikeburke106