active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

fix: use Concurrent::Map instead of Ruby `||=` to make thread safe

Open saiqulhaq opened this issue 1 year ago • 0 comments
trafficstars

Purpose

This PR enhances the thread safety of the cached_result initialization in the ActiveModel::Serializer::LazyAssociation class. By replacing the plain Ruby hash with Concurrent::Map, we aim to prevent potential race conditions and ensure thread-safe operations in multi-threaded environments.

saiqulhaq avatar Jul 03 '24 16:07 saiqulhaq