You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2022/04/15 02:50:52 UTC

[dubbo-go] branch fix/getty-eof updated: fix unit test

This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch fix/getty-eof
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/fix/getty-eof by this push:
     new 5ecfd19e3 fix unit test
     new 0f77532ae Merge pull request #1829 from Lvnszn/fix/getty-eof
5ecfd19e3 is described below

commit 5ecfd19e3be1cfed4ab73e61e78a09c2a6a2b42c
Author: jason <lv...@gmail.com>
AuthorDate: Fri Apr 15 10:41:17 2022 +0800

    fix unit test
---
 protocol/dubbo/impl/codec.go      | 2 +-
 remoting/getty/readwriter_test.go | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go
index 95acbd9e0..e7e6abcc6 100644
--- a/protocol/dubbo/impl/codec.go
+++ b/protocol/dubbo/impl/codec.go
@@ -157,7 +157,7 @@ func (c *ProtocolCodec) Decode(p *DubboPackage) error {
 			return err
 		}
 	}
-	if c.reader.Size() < p.GetBodyLen() {
+	if c.reader.Size() < p.GetBodyLen()+HEADER_LENGTH {
 		return hessian.ErrBodyNotEnough
 	}
 	body, err := c.reader.Peek(p.GetBodyLen())
diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go
index 7eb173234..48e4b3f76 100644
--- a/remoting/getty/readwriter_test.go
+++ b/remoting/getty/readwriter_test.go
@@ -75,8 +75,8 @@ func testDecodeTCPPackage(t *testing.T, svr *Server, client *Client) {
 	assert.True(t, incompletePkgLen >= impl.HEADER_LENGTH, "header buffer too short")
 	incompletePkg := pkgBytes[0 : incompletePkgLen-1]
 	pkg, pkgLen, err := pkgReadHandler.Read(nil, incompletePkg)
-	assert.NoError(t, err)
-	assert.Equal(t, pkg, nil)
+	assert.Equal(t, err.Error(), "body buffer too short")
+	assert.Equal(t, pkg.(*remoting.DecodeResult).Result, nil)
 	assert.Equal(t, pkgLen, 0)
 }