@@ -615,12 +615,18 @@ func (c *Client) Close(ctx context.Context) (err error) {
615615 c .limit = 0
616616
617617 for el := c .waitQ .Front (); el != nil ; el = el .Next () {
618- ch := el .Value .(* chan * session )
618+ ch , ok := el .Value .(* chan * session )
619+ if ! ok {
620+ panic (fmt .Sprintf ("unsupported type conversion from %T to *chan *session" , ch ))
621+ }
619622 close (* ch )
620623 }
621624
622625 for e := c .idle .Front (); e != nil ; e = e .Next () {
623- s := e .Value .(* session )
626+ s , ok := e .Value .(* session )
627+ if ! ok {
628+ panic (fmt .Sprintf ("unsupported type conversion from %T to *session" , s ))
629+ }
624630 s .SetStatus (table .SessionClosing )
625631 c .wg .Add (1 )
626632 go func () {
@@ -745,7 +751,10 @@ func (c *Client) internalPoolGCTick(ctx context.Context, idleThreshold time.Dura
745751 return
746752 }
747753 for e := c .idle .Front (); e != nil ; e = e .Next () {
748- s := e .Value .(* session )
754+ s , ok := e .Value .(* session )
755+ if ! ok {
756+ panic (fmt .Sprintf ("unsupported type conversion from %T to *session" , s ))
757+ }
749758 info , has := c .index [s ]
750759 if ! has {
751760 panic ("session not found in pool" )
@@ -818,7 +827,10 @@ func (c *Client) internalPoolPeekFirstIdle() (s *session, touched time.Time) {
818827 if el == nil {
819828 return
820829 }
821- s = el .Value .(* session )
830+ s , ok := el .Value .(* session )
831+ if ! ok {
832+ panic (fmt .Sprintf ("unsupported type conversion from %T to *session" , s ))
833+ }
822834 info , has := c .index [s ]
823835 if ! has || el != info .idle {
824836 panic ("inconsistent session client index" )
@@ -857,7 +869,10 @@ func (c *Client) internalPoolNotify(s *session) (notified bool) {
857869 // missed something and may want to retry (especially for case (3)).
858870 //
859871 // After that we taking a next waiter and repeat the same.
860- ch := c .waitQ .Remove (el ).(* chan * session )
872+ ch , ok := c .waitQ .Remove (el ).(* chan * session )
873+ if ! ok {
874+ panic (fmt .Sprintf ("unsupported type conversion from %T to *chan *session" , ch ))
875+ }
861876 select {
862877 case * ch <- s :
863878 // Case (1).
0 commit comments