From 5ae6e87218583b359a0b13021c7cbfde28e8b18d Mon Sep 17 00:00:00 2001 From: Dan Walker Date: Thu, 23 Nov 2017 20:29:03 -0800 Subject: [PATCH] Fixes #25: Only add message attribute name if not already there 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. --- .../com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java index 737888a..42dcd75 100644 --- a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java +++ b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java @@ -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);