Skip to content

Commit c52cab9

Browse files
committed
refactor: ensure proper mutex handling in SendCommandTestCase
- Added a deferred unlock for the readMutex in the Run method of SendCommandTestCase to ensure that the mutex is always released, preventing potential deadlocks and improving thread safety.
1 parent 9eb30e4 commit c52cab9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/test_cases/send_command_test_case.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func (t *SendCommandTestCase) Run(client *resp_client.RespConnection, logger *lo
4242
}
4343

4444
t.readMutex.Lock()
45-
value, err = client.ReadValue()
46-
t.readMutex.Unlock()
45+
defer t.readMutex.Unlock()
4746

47+
value, err = client.ReadValue()
4848
if err != nil {
4949
return err
5050
}

0 commit comments

Comments
 (0)