From da95b96986cf4cdbfe1fac1b04402df6862d88a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=9C=E6=AC=A2?= Date: Fri, 17 Jan 2025 01:39:45 +0800 Subject: [PATCH] Fix threadsafe.go threadSafeSet[T].UnmarshalJSON threadSafeSet[T].UnmarshalJSON Can modify threadUnsafeSet data, so need a write lock --- threadsafe.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/threadsafe.go b/threadsafe.go index 664fc61..32f0a58 100644 --- a/threadsafe.go +++ b/threadsafe.go @@ -304,9 +304,9 @@ func (t *threadSafeSet[T]) MarshalJSON() ([]byte, error) { } func (t *threadSafeSet[T]) UnmarshalJSON(p []byte) error { - t.RLock() + t.Lock() err := t.uss.UnmarshalJSON(p) - t.RUnlock() + t.Unlock() return err }