From 01a1bb1d37ba5e5fedfee26c9a3d6a5111469d09 Mon Sep 17 00:00:00 2001 From: dmathieu <42@dmathieu.com> Date: Wed, 24 Jul 2024 09:42:00 +0200 Subject: [PATCH] Write needs a write lock --- .../net/http/otelhttp/internal/request/resp_writer_wrapper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go b/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go index ca5c5e8c778..aea171fb260 100644 --- a/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go +++ b/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go @@ -41,8 +41,8 @@ func NewRespWriterWrapper(w http.ResponseWriter, onWrite func(int64)) *RespWrite // Write writes the bytes array into the [ResponseWriter], and tracks the // number of bytes written and last error. func (w *RespWriterWrapper) Write(p []byte) (int, error) { - w.mu.RLock() - defer w.mu.RUnlock() + w.mu.Lock() + defer w.mu.Unlock() w.writeHeader(http.StatusOK)