[
https://issues.apache.org/jira/browse/THRIFT-1321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13104523#comment-13104523
]
Louis-Philippe Gauthier commented on THRIFT-1321:
-------------------------------------------------
It's broken if you use binary values...
Proto2 = dict:fold(fun(KeyData, ValData, ProtoS0) ->
{ProtoS1, ok} = write(ProtoS0, {KeyType, KeyData}),
{ProtoS2, ok} = write(ProtoS1, {ValType, ValData}),
ProtoS2
end,
Proto1,
Data),
dict:fold/3 always return ValData as a list...
And therefore the the guard (in thrift_binary_protocol) always match the first
one...
write(This0, {string, Str}) when is_list(Str) ->
{This1, ok} = write(This0, {i32, length(Str)}),
{This2, ok} = write(This1, list_to_binary(Str)),
{This2, ok};
write(This0, {string, Bin}) when is_binary(Bin) ->
{This1, ok} = write(This0, {i32, size(Bin)}),
{This2, ok} = write(This1, Bin),
{This2, ok};
> Map serialization is broken in the Erlang library
> -------------------------------------------------
>
> Key: THRIFT-1321
> URL: https://issues.apache.org/jira/browse/THRIFT-1321
> Project: Thrift
> Issue Type: Bug
> Components: Erlang - Library
> Affects Versions: 0.7
> Reporter: Louis-Philippe Gauthier
> Attachments: bug.diff
>
>
> dict:fold/3 always return ValData as a list and therefore breaks the pattern
> matching (guards).
> {quote}
> Dict = dict:new(),
> Dict2 = dict:append("key1", "value1", Dict),
> Dict3 = dict:append("key2", [1,2,3], Dict2),
> Dict4 = dict:append("key3", <<"value3">>, Dict3),
> dict:fold(fun(Key, Value, AccIn) -> io:format("~p : ~p~n", [Key, Value]) end,
> [], Dict4).
> "key1" : ["value1"]
> "key2" : [[1,2,3]]
> "key3" : [<<"value3">>]
> {quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira