mirror of
https://github.com/pgsty/minio.git
synced 2026-07-20 04:30:26 +03:00
tests: Do not allow forced type asserts (#20905)
This commit is contained in:
+10
-10
@@ -23,8 +23,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/minio/minio/internal/bpool"
|
||||
"github.com/minio/minio/internal/hash/sha256"
|
||||
xioutil "github.com/minio/minio/internal/ioutil"
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
@@ -431,12 +431,12 @@ func recycleFunc[RT RoundTripper](newRT func() RT) (newFn func() RT, recycle fun
|
||||
}
|
||||
}
|
||||
}
|
||||
pool := sync.Pool{
|
||||
New: func() interface{} {
|
||||
pool := bpool.Pool[RT]{
|
||||
New: func() RT {
|
||||
return newRT()
|
||||
},
|
||||
}
|
||||
return func() RT { return pool.Get().(RT) },
|
||||
return pool.Get,
|
||||
func(r RT) {
|
||||
if r != rZero {
|
||||
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE!
|
||||
@@ -632,8 +632,8 @@ type StreamTypeHandler[Payload, Req, Resp RoundTripper] struct {
|
||||
// Will be 0 if newReq is nil.
|
||||
InCapacity int
|
||||
|
||||
reqPool sync.Pool
|
||||
respPool sync.Pool
|
||||
reqPool bpool.Pool[Req]
|
||||
respPool bpool.Pool[Resp]
|
||||
id HandlerID
|
||||
newPayload func() Payload
|
||||
nilReq Req
|
||||
@@ -653,13 +653,13 @@ func NewStream[Payload, Req, Resp RoundTripper](h HandlerID, newPayload func() P
|
||||
|
||||
s := newStreamHandler[Payload, Req, Resp](h)
|
||||
if newReq != nil {
|
||||
s.reqPool.New = func() interface{} {
|
||||
s.reqPool.New = func() Req {
|
||||
return newReq()
|
||||
}
|
||||
} else {
|
||||
s.InCapacity = 0
|
||||
}
|
||||
s.respPool.New = func() interface{} {
|
||||
s.respPool.New = func() Resp {
|
||||
return newResp()
|
||||
}
|
||||
s.newPayload = newPayload
|
||||
@@ -682,7 +682,7 @@ func (h *StreamTypeHandler[Payload, Req, Resp]) NewPayload() Payload {
|
||||
// NewRequest creates a new request.
|
||||
// The struct may be reused, so caller should clear any fields.
|
||||
func (h *StreamTypeHandler[Payload, Req, Resp]) NewRequest() Req {
|
||||
return h.reqPool.Get().(Req)
|
||||
return h.reqPool.Get()
|
||||
}
|
||||
|
||||
// PutRequest will accept a request for reuse.
|
||||
@@ -706,7 +706,7 @@ func (h *StreamTypeHandler[Payload, Req, Resp]) PutResponse(r Resp) {
|
||||
// NewResponse creates a new response.
|
||||
// Handlers can use this to create a reusable response.
|
||||
func (h *StreamTypeHandler[Payload, Req, Resp]) NewResponse() Resp {
|
||||
return h.respPool.Get().(Resp)
|
||||
return h.respPool.Get()
|
||||
}
|
||||
|
||||
func newStreamHandler[Payload, Req, Resp RoundTripper](h HandlerID) *StreamTypeHandler[Payload, Req, Resp] {
|
||||
|
||||
Reference in New Issue
Block a user