File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ func (pl *PluginServer) Addr() net.Addr {
9595//
9696// The error value is that of the underlying [net.Listner.Close] call.
9797func (pl * PluginServer ) Close () error {
98+ if pl == nil {
99+ return nil
100+ }
98101 logrus .Trace ("Closing plugin server" )
99102 // Close connections first to ensure the connections get io.EOF instead
100103 // of a connection reset.
Original file line number Diff line number Diff line change @@ -117,6 +117,18 @@ func TestPluginServer(t *testing.T) {
117117 assert .NilError (t , err , "failed to dial returned server" )
118118 checkDirNoNewPluginServer (t )
119119 })
120+
121+ t .Run ("does not panic on Close if server is nil" , func (t * testing.T ) {
122+ var srv * PluginServer
123+ defer func () {
124+ if r := recover (); r != nil {
125+ t .Errorf ("panicked on Close" )
126+ }
127+ }()
128+
129+ err := srv .Close ()
130+ assert .NilError (t , err )
131+ })
120132}
121133
122134func checkDirNoNewPluginServer (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments