diff --git a/.changelog/1f03d280f30349f1822b03d3e6a29fec.json b/.changelog/1f03d280f30349f1822b03d3e6a29fec.json new file mode 100644 index 00000000000..80d086abfb3 --- /dev/null +++ b/.changelog/1f03d280f30349f1822b03d3e6a29fec.json @@ -0,0 +1,8 @@ +{ + "id": "1f03d280-f303-49f1-822b-03d3e6a29fec", + "type": "bugfix", + "description": "Deprecate http.AddResponseReadTimeoutMiddleware.", + "modules": [ + "." + ] +} \ No newline at end of file diff --git a/.changelog/8cb021f3ad794653afac4d9b2d23827f.json b/.changelog/8cb021f3ad794653afac4d9b2d23827f.json new file mode 100644 index 00000000000..329e6b75b91 --- /dev/null +++ b/.changelog/8cb021f3ad794653afac4d9b2d23827f.json @@ -0,0 +1,8 @@ +{ + "id": "8cb021f3-ad79-4653-afac-4d9b2d23827f", + "type": "bugfix", + "description": "Remove arbitrary read timeout on GetRecords which was causing response read panic. See #2752.", + "modules": [ + "service/kinesis" + ] +} \ No newline at end of file diff --git a/aws/transport/http/timeout_read_closer.go b/aws/transport/http/timeout_read_closer.go index 993929bd9b7..4881ae1445b 100644 --- a/aws/transport/http/timeout_read_closer.go +++ b/aws/transport/http/timeout_read_closer.go @@ -64,6 +64,11 @@ func (r *timeoutReadCloser) Close() error { // AddResponseReadTimeoutMiddleware adds a middleware to the stack that wraps the // response body so that a read that takes too long will return an error. +// +// Deprecated: This API was previously exposed to customize behavior of the +// Kinesis service. That customization has been removed and this middleware's +// implementation can cause panics within the standard library networking loop. +// See #2752. func AddResponseReadTimeoutMiddleware(stack *middleware.Stack, duration time.Duration) error { return stack.Deserialize.Add(&readTimeout{duration: duration}, middleware.After) } diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/service/kinesis/KinesisCustomizations.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/service/kinesis/KinesisCustomizations.java deleted file mode 100644 index 675950abb58..00000000000 --- a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/service/kinesis/KinesisCustomizations.java +++ /dev/null @@ -1,51 +0,0 @@ -package software.amazon.smithy.aws.go.codegen.customization.service.kinesis; - -import java.util.List; -import software.amazon.smithy.aws.go.codegen.AwsGoDependency; -import software.amazon.smithy.aws.go.codegen.customization.AwsCustomGoDependency; -import software.amazon.smithy.aws.traits.ServiceTrait; -import software.amazon.smithy.go.codegen.SymbolUtils; -import software.amazon.smithy.go.codegen.integration.GoIntegration; -import software.amazon.smithy.go.codegen.integration.MiddlewareRegistrar; -import software.amazon.smithy.go.codegen.integration.RuntimeClientPlugin; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.shapes.OperationShape; -import software.amazon.smithy.model.shapes.ServiceShape; -import software.amazon.smithy.utils.ListUtils; - -public class KinesisCustomizations implements GoIntegration { - private static final String READ_TIMEOUT_ADDER = "AddResponseReadTimeoutMiddleware"; - private static final String READ_TIMEOUT_DURATION = "ReadTimeoutDuration"; - - @Override - public byte getOrder() { - // We want this to go last so it can be registered at the very end of the list, - // meaning it will be the first to be called after the actual http request is - // made. - return 127; - } - - @Override - public List getClientPlugins() { - return ListUtils.of( - RuntimeClientPlugin.builder() - .operationPredicate(KinesisCustomizations::isGetRecords) - .registerMiddleware(MiddlewareRegistrar.builder() - .resolvedFunction(SymbolUtils.createValueSymbolBuilder(READ_TIMEOUT_ADDER, - AwsGoDependency.AWS_HTTP_TRANSPORT).build()) - .functionArguments(ListUtils.of( - SymbolUtils.createValueSymbolBuilder(READ_TIMEOUT_DURATION, - AwsCustomGoDependency.KINESIS_CUSTOMIZATION).build())) - .build()) - .build() - ); - } - - private static boolean isGetRecords(Model model, ServiceShape service, OperationShape operation) { - return isKinesis(model, service) && operation.getId().getName(service).equals("GetRecords"); - } - - private static boolean isKinesis(Model model, ServiceShape service) { - return service.expectTrait(ServiceTrait.class).getSdkId().equalsIgnoreCase("Kinesis"); - } -} diff --git a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration index 551f10b409e..5febaaa32a9 100644 --- a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration +++ b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration @@ -32,7 +32,6 @@ software.amazon.smithy.aws.go.codegen.customization.service.s3.S3ContentSHA256He software.amazon.smithy.aws.go.codegen.customization.service.s3.BackfillS3ObjectSizeMemberShapeType software.amazon.smithy.aws.go.codegen.customization.service.machinelearning.MachineLearningCustomizations software.amazon.smithy.aws.go.codegen.customization.service.s3.S3AcceptEncodingGzip -software.amazon.smithy.aws.go.codegen.customization.service.kinesis.KinesisCustomizations software.amazon.smithy.aws.go.codegen.customization.service.s3.S3ErrorWith200Status software.amazon.smithy.aws.go.codegen.customization.service.route53.Route53Customizations software.amazon.smithy.aws.go.codegen.customization.PresignURLAutoFill diff --git a/service/kinesis/api_op_GetRecords.go b/service/kinesis/api_op_GetRecords.go index 8647833b199..1351c7a3513 100644 --- a/service/kinesis/api_op_GetRecords.go +++ b/service/kinesis/api_op_GetRecords.go @@ -6,8 +6,6 @@ import ( "context" "fmt" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" - awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" - kinesiscust "github.com/aws/aws-sdk-go-v2/service/kinesis/internal/customizations" "github.com/aws/aws-sdk-go-v2/service/kinesis/types" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" @@ -230,9 +228,6 @@ func (c *Client) addOperationGetRecordsMiddlewares(stack *middleware.Stack, opti if err = addResponseErrorMiddleware(stack); err != nil { return err } - if err = awshttp.AddResponseReadTimeoutMiddleware(stack, kinesiscust.ReadTimeoutDuration); err != nil { - return err - } if err = addRequestResponseLogging(stack, options); err != nil { return err } diff --git a/service/kinesis/internal/customizations/readtimeout.go b/service/kinesis/internal/customizations/readtimeout.go deleted file mode 100644 index 3280e3d72f2..00000000000 --- a/service/kinesis/internal/customizations/readtimeout.go +++ /dev/null @@ -1,8 +0,0 @@ -package customizations - -import ( - "time" -) - -// ReadTimeoutDuration is the read timeout that will be set for certain kinesis operations. -var ReadTimeoutDuration = 5 * time.Second diff --git a/service/kinesis/snapshot/api_op_GetRecords.go.snap b/service/kinesis/snapshot/api_op_GetRecords.go.snap index fb6a06297b0..67218be9d8f 100644 --- a/service/kinesis/snapshot/api_op_GetRecords.go.snap +++ b/service/kinesis/snapshot/api_op_GetRecords.go.snap @@ -48,6 +48,5 @@ GetRecords InterceptBeforeDeserialization AddTimeOffsetMiddleware RecordResponseTiming - ReadResponseTimeout RequestResponseLogger InterceptTransmit