active_model_serializers
active_model_serializers copied to clipboard
fix: use Concurrent::Map instead of Ruby `||=` to make thread safe
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.