Skip to content

fix: loggingStream mutex unlock - #64

Open
Jiang-Gianni wants to merge 1 commit into
go-language-server:mainfrom
Jiang-Gianni:fix-log-mutex
Open

Jiang-Gianni wants to merge 1 commit into
go-language-server:mainfrom
Jiang-Gianni:fix-log-mutex

Conversation

@Jiang-Gianni

Copy link
Copy Markdown

Found this issue while using the logging stream.

In the case *jsonrpc2.Response: branch with an error in the message: the loggingStream mutex is not unlocked before the return, blocking any next call to logCommon

Rather than duplicating the mutex Unlock function call before return it is more idiomatic to use defer right after locking the mutex

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the logCommon method in log.go to use a deferred unlock (defer s.logMu.Unlock()) immediately after acquiring the lock, replacing the manual unlock at the end of the function. This ensures the mutex is safely unlocked even if the function exits early. There are no review comments, and I have no additional feedback to provide.

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.2%. Comparing base (fd04595) to head (cf66ea0).

@@           Coverage Diff           @@
##            main     #64     +/-   ##
=======================================
- Coverage   85.2%   85.2%   -0.1%     
=======================================
  Files         27      27             
  Lines       6135    6134      -1     
=======================================
- Hits        5230    5229      -1     
  Misses       905     905             
Flag Coverage Δ
Linux-ARM64 85.2% <100.0%> (-0.1%) ⬇️
Linux-X64 87.5% <100.0%> (ø)
Files with missing lines Coverage Δ
log.go 100.0% <100.0%> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant