Skip to content

Commit 45b4881

Browse files
committed
Fix bug where messageId may not be instantiated in try block
1 parent 9966b4c commit 45b4881

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)