Skip to content

Commit

Permalink
fix: handle close errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofelletti committed Jul 10, 2024
1 parent ffc2e18 commit a6c38b3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion minio/data_source_minio_s3_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"log"
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -127,7 +128,12 @@ func dataSourceMinioS3ObjectRead(ctx context.Context, d *schema.ResourceData, me
if err != nil {
return diag.FromErr(fmt.Errorf("error reading object: %w", err))
}
defer object.Close()
defer func() {
err := object.Close()
if err != nil {
log.Printf("[WARN] Error closing S3 object source (%s): %s", objectName, err)
}
}()

objectInfo, err := object.Stat()
if err != nil {
Expand Down

0 comments on commit a6c38b3

Please sign in to comment.