Skip to content

Commit eeed424

Browse files
authored
Merge pull request #232 from aws-samples/2025-02-25-java-sqs-batch-bugfix
Fix bug where messageId may not be instantiated in try block
2 parents 9966b4c + 45b4881 commit eeed424

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lambda-function-sqs-report-batch-item-failures/example.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) {
1717
for (SQSEvent.SQSMessage message : sqsEvent.getRecords()) {
1818
try {
1919
//process your message
20-
messageId = message.getMessageId();
2120
} catch (Exception e) {
2221
//Add failed message identifier to the batchItemFailures list
23-
batchItemFailures.add(new SQSBatchResponse.BatchItemFailure(messageId));
22+
batchItemFailures.add(new SQSBatchResponse.BatchItemFailure(message.getMessageId()));
2423
}
2524
}
2625
return new SQSBatchResponse(batchItemFailures);

0 commit comments

Comments
 (0)