Skip to content

Commit

Permalink
Fixes awslabs#25: Only add message attribute name if not already there
Browse files Browse the repository at this point in the history
If someone re-uses the ReceiveMessageRequest object for multiple
calls to AmazonSQSExtendedClient, the latter will add the
RESERVED_ATTRIBUTE_NAME String as a message attribute name every
time. This can cause 413 / Request Entity Too Large errors from
AWS SQS over time.
  • Loading branch information
dsw2127 committed Nov 27, 2017
1 parent 28afe4d commit 5ae6e87
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageR
return super.receiveMessage(receiveMessageRequest);
}

receiveMessageRequest.getMessageAttributeNames().add(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);
if (!receiveMessageRequest.getMessageAttributeNames().contains(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME)) {
receiveMessageRequest.getMessageAttributeNames().add(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);
}

ReceiveMessageResult receiveMessageResult = super.receiveMessage(receiveMessageRequest);

Expand Down

0 comments on commit 5ae6e87

Please sign in to comment.