Protocol message sets JSON size to 0
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.
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.
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.
I would be ok with different names
So, when someone calls getData, how do they know if the returned data is purely JSON in binary format vs. the header info?