Skip to content

Commit

Permalink
Merge pull request #88 from Revolyssup/fixopenfile
Browse files Browse the repository at this point in the history
Fix skipped file closing
  • Loading branch information
leecalcote authored Jul 13, 2022
2 parents 2f78661 + 57d984c commit ba4b412
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 2 additions & 3 deletions adapter/oam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba4b412

Please sign in to comment.