Skip to content

Commit f05099d

Browse files
authored
fix: only call onClose if it's not nil (#39)
1 parent 8a773ac commit f05099d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

protocol/group/selector.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func (s *Selector) NewConnectionEx(ctx context.Context, conn net.Conn, metadata
7575

7676
s.Selector.NewConnectionEx(ctx, conn, metadata, func(it error) {
7777
span.RecordError(it)
78-
onClose(it)
78+
if onClose != nil {
79+
onClose(it)
80+
}
7981
})
8082
}
8183
func (s *Selector) NewPacketConnectionEx(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, onClose network.CloseHandlerFunc) {
@@ -90,6 +92,8 @@ func (s *Selector) NewPacketConnectionEx(ctx context.Context, conn network.Packe
9092

9193
s.Selector.NewPacketConnectionEx(ctx, conn, metadata, func(it error) {
9294
span.RecordError(it)
93-
onClose(it)
95+
if onClose != nil {
96+
onClose(it)
97+
}
9498
})
9599
}

0 commit comments

Comments
 (0)