You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2015/11/01 11:48:54 UTC
[2/6] thrift git commit: THRIFT-2856 refactor erlang basic transports
and unify interfaces Client: Erlang Patch: Nobuaki Sukegawa
THRIFT-2856 refactor erlang basic transports and unify interfaces
Client: Erlang
Patch: Nobuaki Sukegawa
Add read_exact default implementation so that every transport is usable
under framed transport.
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/149ecc1a
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/149ecc1a
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/149ecc1a
Branch: refs/heads/master
Commit: 149ecc1a5fff2f68d413df730b97cc7272813077
Parents: a559f8d
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Sat Oct 31 12:17:31 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Nov 1 18:04:02 2015 +0900
----------------------------------------------------------------------
lib/erl/src/thrift_transport.erl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/149ecc1a/lib/erl/src/thrift_transport.erl
----------------------------------------------------------------------
diff --git a/lib/erl/src/thrift_transport.erl b/lib/erl/src/thrift_transport.erl
index 0fdf970..31dac86 100644
--- a/lib/erl/src/thrift_transport.erl
+++ b/lib/erl/src/thrift_transport.erl
@@ -101,8 +101,12 @@ when is_integer(Len), Len >= 0 ->
read_exact(Transport = #t_transport{module = Module}, Len)
when is_integer(Len), Len >= 0 ->
- {NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
- {Transport#t_transport{state = NewState}, Result}.
+ case erlang:function_exported(Module, read_exact, 2) of
+ true ->
+ {NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
+ {Transport#t_transport{state = NewState}, Result};
+ false -> read(Transport, Len)
+ end.
write(Transport = #t_transport{module = Module}, Data) ->