You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/01/02 18:50:48 UTC
[dubbo-go] branch develop updated: fix protocol linter error
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 69026e8 fix protocol linter error
69026e8 is described below
commit 69026e85321f1ca2443fbcb8bbff8293ecd4d06e
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sun Jan 3 02:50:33 2021 +0800
fix protocol linter error
---
protocol/dubbo/hessian2/hessian_request.go | 20 ++++++++++++++++----
protocol/jsonrpc/http.go | 8 +++++---
protocol/jsonrpc/server.go | 8 ++++++--
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go
index 4ebb4aa..2a1d5f7 100644
--- a/protocol/dubbo/hessian2/hessian_request.go
+++ b/protocol/dubbo/hessian2/hessian_request.go
@@ -30,6 +30,10 @@ import (
perrors "github.com/pkg/errors"
)
+import (
+ "github.com/apache/dubbo-go/common/logger"
+)
+
/////////////////////////////////////////
// dubbo
/////////////////////////////////////////
@@ -221,10 +225,18 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
}
// dubbo version + path + version + method
- encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION)
- encoder.Encode(service.Path)
- encoder.Encode(service.Version)
- encoder.Encode(service.Method)
+ if err := encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION); err != nil {
+ logger.Error("Encode(DEFAULT_DUBBO_PROTOCOL_VERSION) = error: %v", err)
+ }
+ if err := encoder.Encode(service.Path); err != nil {
+ logger.Error("Encode(service.Path) = error: %v", err)
+ }
+ if err := encoder.Encode(service.Version); err != nil {
+ logger.Error("Encode(service.Version) = error: %v", err)
+ }
+ if err := encoder.Encode(service.Method); err != nil {
+ logger.Error("Encode(service.Method) = error: %v", err)
+ }
// args = args type list + args value list
if types, err = getArgsTypeList(args); err != nil {
diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go
index 869617e..7ab1a89 100644
--- a/protocol/jsonrpc/http.go
+++ b/protocol/jsonrpc/http.go
@@ -181,15 +181,17 @@ func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte)
return nil, perrors.WithStack(err)
}
defer tcpConn.Close()
- setNetConnTimeout := func(conn net.Conn, timeout time.Duration) {
+ setNetConnTimeout := func(conn net.Conn, timeout time.Duration) error {
t := time.Time{}
if timeout > time.Duration(0) {
t = time.Now().Add(timeout)
}
- conn.SetDeadline(t)
+ return conn.SetDeadline(t)
+ }
+ if err := setNetConnTimeout(tcpConn, c.options.HTTPTimeout); err != nil {
+ return nil, err
}
- setNetConnTimeout(tcpConn, c.options.HTTPTimeout)
if _, err = reqBuf.WriteTo(tcpConn); err != nil {
return nil, perrors.WithStack(err)
diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go
index 755aa7d..76901bf 100644
--- a/protocol/jsonrpc/server.go
+++ b/protocol/jsonrpc/server.go
@@ -92,7 +92,9 @@ func (s *Server) handlePkg(conn net.Conn) {
t = time.Now().Add(timeout)
}
- conn.SetDeadline(t)
+ if err := conn.SetDeadline(t); err != nil {
+ logger.Error("connection.SetDeadline(t:%v) = error:%v", t, err)
+ }
}
sendErrorResp := func(header http.Header, body []byte) error {
@@ -239,7 +241,9 @@ func (s *Server) Start(url *common.URL) {
s.wg.Add(1)
go func() {
- accept(listener, func(conn net.Conn) { s.handlePkg(conn) })
+ if err := accept(listener, func(conn net.Conn) { s.handlePkg(conn) }); err != nil {
+ logger.Error("accept() = error:%v", err)
+ }
s.wg.Done()
}()