Skip to content

Commit

Permalink
Check error string in addition to type for EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Aug 31, 2017
1 parent 6fd6ed6 commit e032b2a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/database/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mongodb

import (
"io"
"strings"
"time"

"encoding/json"
Expand Down Expand Up @@ -128,7 +129,7 @@ func (m *MongoDB) CreateUser(statements dbplugin.Statements, usernameConfig dbpl
err = session.DB(mongoCS.DB).Run(createUserCmd, nil)
switch err {
case nil:
case io.EOF:
case io.EOF || strings.Contains(err.Error(), "EOF"):
if err := m.ConnectionProducer.Close(); err != nil {
return "", "", errwrap.Wrapf("error closing EOF'd mongo connection: {{err}}", err)
}
Expand Down Expand Up @@ -184,7 +185,7 @@ func (m *MongoDB) RevokeUser(statements dbplugin.Statements, username string) er
switch err {
case nil:
case mgo.ErrNotFound:
case io.EOF:
case io.EOF || strings.Contains(err.Error(), "EOF"):
if err := m.ConnectionProducer.Close(); err != nil {
return errwrap.Wrapf("error closing EOF'd mongo connection: {{err}}", err)
}
Expand Down

0 comments on commit e032b2a

Please sign in to comment.