Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http/server.go var pool in function newBufioWriterSize(io.Writer, int) *bufio.Writer Get return nil #39673

snowdusk opened this issue Jun 18, 2020 · 2 comments


Copy link

@snowdusk snowdusk commented Jun 18, 2020

What version of Go are you using (go version)?

$ go version

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

What did you expect to see?

Because there is no New function supplied for bufioWriter2kPool and bufioWriter4kPool, every time pool Get return nil.
func newBufioWriterSize(w io.Writer, size int) *bufio.Writer {

    pool := bufioWriterPool(size)  // should  delete or supply New func
    if pool != nil {
            if v := pool.Get(); v != nil {
                    bw := v.(*bufio.Writer)
                    return bw
    return bufio.NewWriterSize(w, size)


What did you see instead?

Copy link

@andybons andybons commented Jun 18, 2020

Duplicate of #39648

Unless you have found a bug, please use one of the other forums mentioned in #39648 for asking a question instead of the issue tracker. Thanks.

@andybons andybons closed this Jun 18, 2020
Copy link

@davecheney davecheney commented Jun 18, 2020

@wangsong93 the buffer pools are lazily initialised by filling the pool with entries in putBufioWriter rather than using a New function. This is because the bufio.Writer's returned from the pool must be a specific size which is best handled in newBufioWriterSize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.