File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ func (pl *PluginServer) Addr() net.Addr {
95
95
//
96
96
// The error value is that of the underlying [net.Listner.Close] call.
97
97
func (pl * PluginServer ) Close () error {
98
+ if pl == nil {
99
+ return nil
100
+ }
98
101
logrus .Trace ("Closing plugin server" )
99
102
// Close connections first to ensure the connections get io.EOF instead
100
103
// of a connection reset.
Original file line number Diff line number Diff line change @@ -117,6 +117,18 @@ func TestPluginServer(t *testing.T) {
117
117
assert .NilError (t , err , "failed to dial returned server" )
118
118
checkDirNoNewPluginServer (t )
119
119
})
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
+ })
120
132
}
121
133
122
134
func checkDirNoNewPluginServer (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments