Skip to content

BufferRecycler should avoid setting replacement if one already returned, bigger #1186

Description

@cowtowncoder

(based on discussion FasterXML/jackson#204 -- good suggestion by @kkkkkhhhh)

It seems that BufferRecycler will always replace assigned buffer when release method is called. But it would probably make sense to only replace null or smaller buffer, and avoid replacing bigger buffer with smaller.
While in the original expected usage sequence should always be "alloc / release / allow / release" (in which case "release" would be replacing null), there can be cases where this does not hold (multiple parsers/generators per thread, concurrently; but also just parser-and-generator case).

So let's add some basic checking into release method.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssue related to performance problems or enhancements

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions