FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
316 stars 136 forks source link

Fix #384: change handling of SmileBufferRecycler to be thread-safe #385

Closed cowtowncoder closed 1 year ago

cowtowncoder commented 1 year ago

Simplify SmileBufferRecycler by using AtomicReference to guard access to buffers. This didn't use to be problematic before async handling (when there was typically 1-to-1 matching between threads and Parser/Generator instances). However, this changed for both:

  1. Async Smile parser
  2. Non-blocking frameworks where access to input is not handled with BIO (and as a result there's no thread-to-parser/generator binding)

and so there's no guarantee of atomicity for reuse by recycler.

cowtowncoder commented 1 year ago

@simondaudin I think this should fix it; will merge but would appreciate if you could verify on your end. Targeting 2.15 branch for eventual 2.15.3 release (and 2.16.0).

simondaudin commented 1 year ago

@cowtowncoder Thank you for the fix, that was fast ! I tested with: