diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go index d7d305681808c64b452750e7d475c384b5f31d22..695ca21b0ed53dcf94907223e4c222af17311db9 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/least_active.go @@ -50,7 +50,7 @@ func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation var ( leastActive int32 = -1 // The least active value of all invokers totalWeight int64 = 0 // The number of invokers having the same least active value (LEAST_ACTIVE) - firstWeight int64 = 0 // Initial value, used for comparision + firstWeight int64 = 0 // Initial value, used for comparison leastIndexes = make([]int, count) // The index of invokers having the same least active value (LEAST_ACTIVE) leastCount = 0 // The number of invokers having the same least active value (LEAST_ACTIVE) sameWeight = true // Every invoker has the same weight value? diff --git a/config/service_config_test.go b/config/service_config_test.go index 77cbbff386fcee1e27b59bc7e2718a8d1929af38..99835f63069dabcc3d0a3a58f9e57b6a6b0bc63d 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -122,7 +122,8 @@ func Test_Export(t *testing.T) { doinit() extension.SetProtocol("registry", GetProtocol) - for _, service := range providerConfig.Services { + for i := 0; i < len(providerConfig.Services); i++ { + service := providerConfig.Services[i] service.Implement(&MockService{}) service.Export() assert.Condition(t, func() bool { diff --git a/protocol/dubbo/client_test.go b/protocol/dubbo/client_test.go index 1ea9e4fb0e02a1e1234e8026f5a291398508133c..f4a5f4a8474b30b13bf7598bc634ac722955d91b 100644 --- a/protocol/dubbo/client_test.go +++ b/protocol/dubbo/client_test.go @@ -40,7 +40,7 @@ func TestClient_CallOneway(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) @@ -57,7 +57,7 @@ func TestClient_Call(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) @@ -118,7 +118,7 @@ func TestClient_AsyncCall(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) diff --git a/protocol/dubbo/codec.go b/protocol/dubbo/codec.go index e9ced8449404dd31e7d2c7694d15a3a4756e36a1..cb57fc896f5e1c0be99a1e5978841ae17503064b 100644 --- a/protocol/dubbo/codec.go +++ b/protocol/dubbo/codec.go @@ -40,9 +40,9 @@ const ( type CallType int32 const ( - CT_UNKOWN CallType = 0 - CT_OneWay CallType = 1 - CT_TwoWay CallType = 2 + CT_UNKNOWN CallType = 0 + CT_OneWay CallType = 1 + CT_TwoWay CallType = 2 ) //////////////////////////////////////////// diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 4368bb4630900eb2c4eece760b3b3e5c4887c478..182d6d8e0b11cfcb231789cebf9c4cefdecfa258 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -36,7 +36,7 @@ func TestDubboInvoker_Invoke(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 3543d8da803b00befe9e08286bd67c09cd0afef2..26ce4a1906d5d6fe425f23984586914c293f47a4 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -48,7 +48,7 @@ func TestDubboProtocol_Export(t *testing.T) { eq := exporter.GetInvoker().GetUrl().URLEqual(url) assert.True(t, eq) - // second service: the same path and the diferent version + // second service: the same path and the different version url2, err := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&"+ "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&"+ "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&"+ diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index 15e222676afe5579fc53df46a3983b55e5d3f2b4..55ee929301e4e62e6b868c5b85b9952fc354b723 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -190,7 +190,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) { p, ok := pkg.(*DubboPackage) if !ok { - logger.Errorf("illegal packge{%#v}", pkg) + logger.Errorf("illegal package{%#v}", pkg) return } p.Header.ResponseStatus = hessian.Response_OK diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 5b5548067225bcf6d8bcbaf35cee63c829c03edc..22dc7cfc49c978a7c042652158210ef6fda48892 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -152,7 +152,9 @@ func (s *Server) handlePkg(conn net.Conn) { timeout, err := time.ParseDuration(reqHeader["Timeout"]) if err == nil { httpTimeout = timeout - ctx, _ = context.WithTimeout(ctx, httpTimeout) + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, httpTimeout) + defer cancel() } delete(reqHeader, "Timeout") }