Skip to content

NullReferenceException thrown from AmazonS3Client.Begin/EndGetObject if no internet connection #274

Closed
@callorico

Description

@callorico

Using 3.1.3.5 with .NET 4.0 Client Profile

The following works fine if I have an active internet connection:

using (IAmazonS3 s3Client = new AmazonS3Client())
{
    // Setup request for putting an object in S3.                 
    GetObjectRequest request = new GetObjectRequest
    {
        BucketName = "<bucket>",
        Key = "<key>",
    };

    IAsyncResult result = s3Client.BeginGetObject(request, null, null);

    GetObjectResponse response = s3Client.EndGetObject(result);
    response.WriteResponseStreamToFile("test.out");
}

However, if I disable my network adapter prior to running the above, a NullReferenceException is thrown out of the SDK with the following stack trace:

   at Amazon.Runtime.Internal.RedirectHandler.HandleRedirect(IExecutionContext executionContext) in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:line 101
   at Amazon.Runtime.Internal.RedirectHandler.InvokeAsyncCallback(IAsyncExecutionContext executionContext) in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:line 75
   at Amazon.Runtime.Internal.PipelineHandler.AsyncCallback(IAsyncExecutionContext executionContext) in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\PipelineHandler.cs:line 95
   at Amazon.Runtime.AmazonServiceClient.EndInvoke[TResponse](IAsyncResult result) in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AmazonServiceClient.cs:line 212
   at Amazon.S3.AmazonS3Client.EndGetObject(IAsyncResult asyncResult) in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Services\S3\Generated\_bcl35\AmazonS3Client.cs:line 1956
   at S3Test.Program.Main(String[] args) in c:\Users\callorico\Desktop\S3Test\S3Test\Program.cs:line 28

In this scenario, I would expect to see a network exception of some type. If I replace the APM code with a synchronous s3Client.GetObject call then I do see an AmazonServiceException with a nested WebException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions