Skip to content

Commit c387167

Browse files
authored
Fixed race condition in builder (#704)
1 parent b55722f commit c387167

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: legacy/builder/i18n/i18n.go

+7
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ type Logger interface {
4040
type LoggerToCustomStreams struct {
4141
Stdout io.Writer
4242
Stderr io.Writer
43+
mux sync.Mutex
4344
}
4445

4546
func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string, a ...interface{}) {
47+
s.mux.Lock()
48+
defer s.mux.Unlock()
4649
target := s.Stdout
4750
if w == os.Stderr {
4851
target = s.Stderr
@@ -51,6 +54,8 @@ func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string
5154
}
5255

5356
func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) {
57+
s.mux.Lock()
58+
defer s.mux.Unlock()
5459
target := s.Stdout
5560
if w == os.Stderr {
5661
target = s.Stderr
@@ -59,6 +64,8 @@ func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) {
5964
}
6065

6166
func (s LoggerToCustomStreams) UnformattedWrite(w io.Writer, data []byte) {
67+
s.mux.Lock()
68+
defer s.mux.Unlock()
6269
target := s.Stdout
6370
if w == os.Stderr {
6471
target = s.Stderr

0 commit comments

Comments
 (0)