You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2015/06/26 21:55:51 UTC

thrift git commit: THRIFT-3205 TCompactProtocol return a wrong error when the io.EOF happens Client: Go Patch: Wang Jing

Repository: thrift
Updated Branches:
  refs/heads/master 2238adabb -> 3f2e71015


THRIFT-3205 TCompactProtocol return a wrong error when the io.EOF happens
Client: Go
Patch: Wang Jing <wa...@BYTEDANCE.com>

This closes #530


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/3f2e7101
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/3f2e7101
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/3f2e7101

Branch: refs/heads/master
Commit: 3f2e7101523bd326577e564c3d154a22082456e7
Parents: 2238ada
Author: Jens Geyer <je...@apache.org>
Authored: Fri Jun 26 21:54:35 2015 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Jun 26 21:55:05 2015 +0200

----------------------------------------------------------------------
 lib/go/thrift/compact_protocol.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/3f2e7101/lib/go/thrift/compact_protocol.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
index ecff814..1a7a8da 100644
--- a/lib/go/thrift/compact_protocol.go
+++ b/lib/go/thrift/compact_protocol.go
@@ -329,17 +329,24 @@ func (p *TCompactProtocol) WriteBinary(bin []byte) error {
 
 // Read a message header.
 func (p *TCompactProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) {
+
 	protocolId, err := p.ReadByte()
+	if err != nil {
+		return
+	}
+
 	if protocolId != COMPACT_PROTOCOL_ID {
 		e := fmt.Errorf("Expected protocol id %02x but got %02x", COMPACT_PROTOCOL_ID, protocolId)
 		return "", typeId, seqId, NewTProtocolExceptionWithType(BAD_VERSION, e)
 	}
+
 	versionAndType, err := p.ReadByte()
-	version := versionAndType & COMPACT_VERSION_MASK
-	typeId = TMessageType((versionAndType >> COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_BITS)
 	if err != nil {
 		return
 	}
+
+	version := versionAndType & COMPACT_VERSION_MASK
+	typeId = TMessageType((versionAndType >> COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_BITS)
 	if version != COMPACT_VERSION {
 		e := fmt.Errorf("Expected version %02x but got %02x", COMPACT_VERSION, version)
 		err = NewTProtocolExceptionWithType(BAD_VERSION, e)