File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ func (c *Client) Connect(ctx context.Context) error {
100
100
// or write operations. If this method returns with no errors, all connections
101
101
// associated with this Client have been closed.
102
102
func (c * Client ) Disconnect (ctx context.Context ) error {
103
+ if ctx == nil {
104
+ ctx = context .Background ()
105
+ }
106
+
103
107
c .endSessions (ctx )
104
108
return replaceTopologyErr (c .topology .Disconnect (ctx ))
105
109
}
Original file line number Diff line number Diff line change @@ -538,3 +538,13 @@ func TestClient_Ping_InvalidHost(t *testing.T) {
538
538
err = c .Ping (ctx , nil )
539
539
require .NotNil (t , err )
540
540
}
541
+
542
+ func TestClient_Disconnect_NilContext (t * testing.T ) {
543
+ cs := testutil .ConnString (t )
544
+ c , err := NewClient (cs .String ())
545
+ require .NoError (t , err )
546
+ err = c .Connect (nil )
547
+ require .NoError (t , err )
548
+ err = c .Disconnect (nil )
549
+ require .NoError (t , err )
550
+ }
You can’t perform that action at this time.
0 commit comments