Skip to content

Commit

Permalink
remove the Initialize wrap and call close explicitly (#3769)
Browse files Browse the repository at this point in the history
  • Loading branch information
briankassouf authored Jan 10, 2018
1 parent 166db92 commit a2b9ce7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
1 change: 1 addition & 0 deletions builtin/logical/database/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (b *databaseBackend) createDBObj(ctx context.Context, s logical.Storage, na

err = db.Initialize(ctx, config.ConnectionDetails, true)
if err != nil {
db.Close()
return nil, err
}

Expand Down
11 changes: 0 additions & 11 deletions builtin/logical/database/dbplugin/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dbplugin

import (
"context"
"errors"
"sync"

Expand All @@ -28,16 +27,6 @@ func (dc *DatabasePluginClient) Close() error {
return err
}

// This wraps the Initialize call and ensures we close the plugin on error.
func (dc *DatabasePluginClient) Initialize(ctx context.Context, config map[string]interface{}, verifyConnection bool) error {
err := dc.Database.Initialize(ctx, config, verifyConnection)
if err != nil {
dc.Close()
}

return err
}

// newPluginClient returns a databaseRPCClient with a connection to a running
// plugin. The client is wrapped in a DatabasePluginClient object to ensure the
// plugin is killed on call of Close().
Expand Down
1 change: 1 addition & 0 deletions builtin/logical/database/path_config_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (b *databaseBackend) connectionWriteHandler() framework.OperationFunc {

err = db.Initialize(ctx, config.ConnectionDetails, verifyConnection)
if err != nil {
db.Close()
return logical.ErrorResponse(fmt.Sprintf("error creating database object: %s", err)), nil
}

Expand Down

0 comments on commit a2b9ce7

Please sign in to comment.