diff --git a/adapter/adapter.go b/adapter/adapter.go index 3ef5a4f..ae785c0 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -49,8 +49,8 @@ type Adapter struct { mx sync.Mutex } -func (a *Adapter) SetChannel(hchan *chan interface{}) { - a.mx.Lock() - defer a.mx.Unlock() - a.Channel = hchan +func (h *Adapter) SetChannel(hchan *chan interface{}) { + h.mx.Lock() + defer h.mx.Unlock() + h.Channel = hchan } diff --git a/adapter/oam.go b/adapter/oam.go index 434d1c1..14f1d8e 100644 --- a/adapter/oam.go +++ b/adapter/oam.go @@ -104,14 +104,13 @@ func (or *OAMRegistrant) Register() error { if err != nil { return ErrOpenOAMDefintionFile(err) } - defer func() { - _ = definition.Close() - }() definitionMap := map[string]interface{}{} if err := json.NewDecoder(definition).Decode(&definitionMap); err != nil { + _ = definition.Close() return ErrJSONMarshal(err) } + _ = definition.Close() ord.OAMDefinition = definitionMap schema, err := ioutil.ReadFile(dpath.OAMRefSchemaPath)