[GitHub] thrift pull request #1316: THRIFT-4266: Erlang skip fix
Github user asfgit closed the pull request at: https://github.com/apache/thrift/pull/1316 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] thrift pull request #1316: THRIFT-4266: Erlang skip fix
Github user dhull commented on a diff in the pull request: https://github.com/apache/thrift/pull/1316#discussion_r129976272 --- Diff: lib/erl/test/test_omit.erl --- @@ -0,0 +1,82 @@ +-module(test_omit). + +-include("gen-erl/thrift_omit_with_types.hrl"). + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +omit_struct1_test() -> + %% In this test, the field that is deleted is a basic type (an i32). + A = #test1{one = 1, three = 3}, + B = #test1{one = 1, two = 2, three = 3}, + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), + + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), + {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), + ?assertEqual(element(1, A), element(1, O0)), + ?assertEqual(element(2, A), element(2, O0)), + ?assertEqual(element(4, A), element(3, O0)), + + {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P4, {ok, O1}} = thrift_protocol:read(P3, {struct, {thrift_omit_without_types, element(1, A)}}), + %% io:format(user, "~p ~p\n", [ A, O1 ]), --- End diff -- OK, will do. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] thrift pull request #1316: THRIFT-4266: Erlang skip fix
Github user djnym commented on a diff in the pull request: https://github.com/apache/thrift/pull/1316#discussion_r129973811 --- Diff: lib/erl/test/test_omit.erl --- @@ -0,0 +1,82 @@ +-module(test_omit). + +-include("gen-erl/thrift_omit_with_types.hrl"). + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +omit_struct1_test() -> + %% In this test, the field that is deleted is a basic type (an i32). + A = #test1{one = 1, three = 3}, + B = #test1{one = 1, two = 2, three = 3}, + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), + + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), + {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), + ?assertEqual(element(1, A), element(1, O0)), + ?assertEqual(element(2, A), element(2, O0)), + ?assertEqual(element(4, A), element(3, O0)), + + {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P4, {ok, O1}} = thrift_protocol:read(P3, {struct, {thrift_omit_without_types, element(1, A)}}), + %% io:format(user, "~p ~p\n", [ A, O1 ]), --- End diff -- And there are about 3-4 other commented out lines which can probably be removed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] thrift pull request #1316: THRIFT-4266: Erlang skip fix
Github user djnym commented on a diff in the pull request: https://github.com/apache/thrift/pull/1316#discussion_r129973689 --- Diff: lib/erl/test/test_omit.erl --- @@ -0,0 +1,82 @@ +-module(test_omit). + +-include("gen-erl/thrift_omit_with_types.hrl"). + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +omit_struct1_test() -> + %% In this test, the field that is deleted is a basic type (an i32). + A = #test1{one = 1, three = 3}, + B = #test1{one = 1, two = 2, three = 3}, + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), + + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), + {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), + ?assertEqual(element(1, A), element(1, O0)), + ?assertEqual(element(2, A), element(2, O0)), + ?assertEqual(element(4, A), element(3, O0)), + + {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P4, {ok, O1}} = thrift_protocol:read(P3, {struct, {thrift_omit_without_types, element(1, A)}}), + %% io:format(user, "~p ~p\n", [ A, O1 ]), --- End diff -- Probably don't need this commented out line. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] thrift pull request #1316: THRIFT-4266: Erlang skip fix
GitHub user dhull opened a pull request: https://github.com/apache/thrift/pull/1316 THRIFT-4266: Erlang skip fix The Erlang library has a bug that causes it to crash when attempting to skip over a struct that it receives that does not exist in its thrift definition. This will happen when the client and server are using different versions of the thrift definition where one of the versions adds a struct field to an existing struct. This pull request has two commits. The first commit adds a test that fails with the existing Erlang library. The second commit fixes the bug. The bug was that the `erlang_protocol:skip` function expects an atom as its second (Type) argument, but the calls in `skip_struct_loop`, `skip_map_loop`, `skip_set_loop`, and `skip_list_loop` did not convert from the integer type decoded from the buffer to the corresponding atom. You can merge this pull request into a Git repository by running: $ git pull https://github.com/dhull/thrift thrift-4266-erlang-skip-fix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/1316.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1316 commit 79874dbe079fbabba663568e5ed31ffab540329a Author: David HullDate: 2017-07-26T21:27:02Z THRIFT-4266: Fix skipping of unknown fields in Erlang client. commit 8fd55cc7685ea2ea22016296936789572dd83c56 Author: David Hull Date: 2017-07-27T00:15:00Z THRIFT-4266: Add Erlang deleted field test. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---