Skip to content

Preserve existing getObject files - #7353

Merged
davidh44 merged 1 commit into
masterfrom
hdavidh/fix-s3-async-file-cleanup
Sep 5, 2026
Merged

Preserve existing getObject files#7353
davidh44 merged 1 commit into
masterfrom
hdavidh/fix-s3-async-file-cleanup

Conversation

@davidh44

@davidh44 davidh44 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

FileAsyncResponseTransformer deleted the destination whenever FailureBehavior.DELETE was configured, even when the current request attempt failed before opening the file. With CREATE_NEW, this could delete a pre-existing file and allow a retry to silently replace it.

Modifications

This change resets file-channel state for each attempt, clears it during failure cleanup, and deletes the destination only when the current attempt successfully opened it. Existing files are preserved when opening fails or the request fails before writing. Partial output is still deleted after a successful open when FailureBehavior.DELETE is configured.

Behavior change: an async download with CREATE_NEW onto an existing destination now surfaces
FileAlreadyExistsException instead of deleting the file and letting the retry overwrite it.

Callers that intentionally require replacement behavior should use getObject(request, AsyncResponseTransformer.toFile(path, FileTransformerConfiguration.defaultCreateOrReplaceExisting())).

Testing

Added unit tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@davidh44
davidh44 requested a review from a team as a code owner September 4, 2026 18:54
@davidh44 davidh44 added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Sep 4, 2026
@davidh44
davidh44 added this pull request to the merge queue Sep 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 4, 2026
@davidh44
davidh44 added this pull request to the merge queue Sep 4, 2026
@davidh44
davidh44 removed this pull request from the merge queue due to a manual request Sep 4, 2026
@davidh44
davidh44 added this pull request to the merge queue Sep 4, 2026
Merged via the queue into master with commit 8b038c7 Sep 5, 2026
25 of 26 checks passed
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 5, 2026
@davidh44
davidh44 deleted the hdavidh/fix-s3-async-file-cleanup branch September 5, 2026 04:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants