Skip to content

Commit

Permalink
replace defer with manual close. defer is not good since should be cl…
Browse files Browse the repository at this point in the history
…osed before uploading
  • Loading branch information
davemarco committed Jul 3, 2024
1 parent 304476e commit 5373934
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/out_clp_s3/flush/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func ToS3(data unsafe.Pointer, length int, tag string, ctx *outctx.S3Context) (i
err = fmt.Errorf("error opening zstd writer: %w", err)
return output.FLB_RETRY, err
}
defer zstdWriter.Close()

// IR buffer using bytes.Buffer internally, so it will dynamically grow if undersized. Using
// FourByteEncoding as default encoding.
Expand All @@ -107,6 +106,11 @@ func ToS3(data unsafe.Pointer, length int, tag string, ctx *outctx.S3Context) (i
return output.FLB_RETRY, err
}

err = zstdWriter.Close()
if err != nil {
return output.FLB_RETRY, err
}

outputLocation, err := uploadToS3(
ctx.Config.S3Bucket,
ctx.Config.S3BucketPrefix,
Expand Down

0 comments on commit 5373934

Please sign in to comment.