Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in file-based AsyncResponseTransformer that could cause a… #5220

Merged
merged 5 commits into from
May 14, 2024

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented May 13, 2024

… streaming request to hang if an exception was thrown from onStream

Motivation and Context

Currently, if an exception is thrown from FileAsyncResponseTransformer#onStream(example stacktrace provided below), the future will never be completed, causing the streaming request to hang.

Exception in thread "AwsEventLoop 9" java.io.UncheckedIOException: java.nio.file.FileSystemException: /Downloads: Is a directory
    at software.amazon.awssdk.utils.FunctionalUtils.asRuntimeException(FunctionalUtils.java:180)
    at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:110)
    at software.amazon.awssdk.utils.FunctionalUtils.invokeSafely(FunctionalUtils.java:136)
    at software.amazon.awssdk.core.internal.async.FileAsyncResponseTransformer.onStream(FileAsyncResponseTransformer.java:125)
    at software.amazon.awssdk.core.async.listener.AsyncResponseTransformerListener$NotifyingAsyncResponseTransformer.onStream(AsyncResponseTransformerListener.java:93)
    at software.amazon.awssdk.core.async.listener.AsyncResponseTransformerListener$NotifyingAsyncResponseTransformer.onStream(AsyncResponseTransformerListener.java:93)
    at software.amazon.awssdk.core.internal.http.async.AsyncStreamingResponseHandler.onStream(AsyncStreamingResponseHandler.java:63)
    at software.amazon.awssdk.core.internal.http.IdempotentAsyncResponseHandler.onStream(IdempotentAsyncResponseHandler.java:108)
    at software.amazon.awssdk.core.internal.http.async.CombinedResponseAsyncHttpResponseHandler.onStream(CombinedResponseAsyncHttpResponseHandler.java:86)
    at software.amazon.awssdk.core.internal.http.async.AsyncAfterTransmissionInterceptorCallingResponseHandler.onStream(AsyncAfterTransmissionInterceptorCallingResponseHandler.java:86)
    at software.amazon.awssdk.core.internal.http.async.FilterTransformingAsyncHttpResponseHandler.onStream(FilterTransformingAsyncHttpResponseHandler.java:49)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage$ReadMetricsTrackingResponseHandler.onStream(MakeAsyncHttpRequestStage.java:313)
    at software.amazon.awssdk.services.s3.internal.crt.S3CrtResponseHandlerAdapter.initiateResponseHandling(S3CrtResponseHandlerAdapter.java:175)
    at software.amazon.awssdk.services.s3.internal.crt.S3CrtResponseHandlerAdapter.onFinished(S3CrtResponseHandlerAdapter.java:134)
    at software.amazon.awssdk.crt.s3.S3MetaRequestResponseHandlerNativeAdapter.onFinished(S3MetaRequestResponseHandlerNativeAdapter.java:25)
Caused by: java.nio.file.FileSystemException: /Downloads: Is a directory
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
    at java.base/sun.nio.fs.UnixFileSystemProvider.newAsynchronousFileChannel(UnixFileSystemProvider.java:201)
    at java.base/java.nio.channels.AsynchronousFileChannel.open(AsynchronousFileChannel.java:253)
    at software.amazon.awssdk.core.internal.async.FileAsyncResponseTransformer.createChannel(FileAsyncResponseTransformer.java:103)
    at software.amazon.awssdk.core.internal.async.FileAsyncResponseTransformer.lambda$onStream$2(FileAsyncResponseTransformer.java:125)
    at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:108)
    ... 13 more

Modifications

Catch exceptions thrown from FileAsyncResponseTransformer#onError and invoke exceptionOcurred which will complete the future exceptionally.

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

… streaming request to hang if an exception was thrown from onStream
@zoewangg zoewangg requested a review from a team as a code owner May 13, 2024 22:39
@zoewangg zoewangg enabled auto-merge (squash) May 14, 2024 20:44
@zoewangg zoewangg disabled auto-merge May 14, 2024 21:49
@zoewangg zoewangg enabled auto-merge (squash) May 14, 2024 21:49
Copy link

sonarcloud bot commented May 14, 2024

@zoewangg zoewangg merged commit 57de751 into master May 14, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants