transit-ruby: cache reading and writing not the same

20 views
Skip to first unread message

jwkoe...@gmail.com

unread,
Oct 10, 2016, 7:54:40 AM10/10/16
to transit-format
Hello,

The Ruby implementation of the Transit Reader uses the RollingCache different from the Writer, resulting in incorrect decoded values.

This can result in wrong strings being retrieved from the cache, so that the read value is not what one would expect.

It becomes especially apparent when one uses a Tag name that is the same as a key in a map:

["~#person",["^ ","name","J.W. Koelewijn","address",["~#address",["^ ","street","Main str","number",15]],"^5",["~#number",["^ ","area","555","^5","12345678"]]]]

In the default Ruby implementation, the Decoder would resolve ^5 as 'area', and not as 'number', because the parsed value is written to the cache, which means that both 'number' and '~#number' are stored in under the same key, resulting in problems later in the decoding.

I know the example looks a bit contrived, but it is derived from a real world example, in which we have tag and key names that are equal (like 'number' in the example given above).

I have created a Pull Request on Github, not because I expect it will be merged, but more to give a failing test and a solution.


Kind regards,

J.W. Koelewijn

Reply all
Reply to author
Forward
0 new messages