Jens Geyer created THRIFT-6289:
----------------------------------
Summary: Erlang: the JSON protocol does not interoperate with the
other bindings
Key: THRIFT-6289
URL: https://issues.apache.org/jira/browse/THRIFT-6289
Project: Thrift
Issue Type: Bug
Components: Erlang - Compiler, Erlang - Library
Reporter: Jens Geyer
Follow-up to THRIFT-6279, which makes {{thrift_json_protocol}} read the
messages it writes. It still differs from the JSON protocol of the other
bindings, checked against C++ and Java {{TJSONProtocol}}, in these places:
* *Booleans.* Erlang writes {{true}} and {{false}}. The other bindings write
and expect {{1}} and {{0}}.
* *Binary fields.* The other bindings write them base64-encoded. The generated
Erlang type info gives {{string}} and {{binary}} fields the same type,
{{string}}; for example, {{testBinary}} has the params type {{\{struct, [\{1,
string\}]\}}}. So the protocol cannot tell which fields to encode.
* *Doubles.* C++ writes an integral double without a fraction, for example
{{1}}, and the Erlang reader refuses that as not a double. NaN and the
infinities are written as the strings {{"NaN"}}, {{"Infinity"}} and
{{"-Infinity"}}. Erlang floats cannot hold these values, so reading them can
only fail, and it should fail cleanly.
The Erlang cross test runs only binary and compact, so none of this shows there.
h2. Suggested
* Write booleans as {{1}} and {{0}}, and read both forms.
* Read an integer where a double is expected.
* Give binary fields a type term of their own in the generated type info. Every
Erlang protocol then has to accept it, and the JSON protocol base64-encodes
such fields.
* Then add {{json}} to the Erlang entry of {{test/tests.json}}, and add the
{{testBinary}} call that {{test/erl/src/test_client.erl}} still has as a TODO.
_Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)