Skip to content

Commit

Permalink
Fix tests hungup
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby committed Apr 26, 2024
1 parent 6cc59c7 commit 859a140
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions internal/topic/topicwriterinternal/writer_reconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,17 @@ func (w *WriterReconnector) Flush(ctx context.Context) error {
}

func (w *WriterReconnector) Close(ctx context.Context) error {
return w.close(ctx, xerrors.WithStackTrace(errStopWriterReconnector))
reason := xerrors.WithStackTrace(errStopWriterReconnector)
w.queue.StopAddNewMessages(reason)

flushErr := w.Flush(ctx)
closeErr := w.close(ctx, reason)

if flushErr != nil {
return flushErr
}

return closeErr
}

func (w *WriterReconnector) close(ctx context.Context, reason error) (resErr error) {
Expand All @@ -339,10 +349,6 @@ func (w *WriterReconnector) close(ctx context.Context, reason error) (resErr err
onDone(resErr)
}()

w.queue.StopAddNewMessages(reason)

resErr = w.Flush(ctx)

closeErr := w.queue.Close(reason)
if resErr == nil && closeErr != nil {
resErr = closeErr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ func TestWriterImpl_WriteCodecs(t *testing.T) {
Data: bytes.NewReader(messContent),
}}))

require.Equal(t, rawtopiccommon.CodecRaw, <-messReceived)
mess := <-messReceived
require.Equal(t, rawtopiccommon.CodecRaw, mess)
})
t.Run("ForceGzip", func(t *testing.T) {
var err error
Expand Down

0 comments on commit 859a140

Please sign in to comment.