@@ -602,11 +602,11 @@ private ReceiveMessageRequest doCreateReceiveMessageRequest(Duration pollTimeout
602
602
ReceiveMessageRequest .Builder builder = ReceiveMessageRequest .builder ().queueUrl (attributes .getQueueUrl ())
603
603
.maxNumberOfMessages (maxNumberOfMessages ).messageAttributeNames (this .messageAttributeNames )
604
604
.attributeNamesWithStrings (this .messageSystemAttributeNames )
605
- .waitTimeSeconds (pollTimeout .toSecondsPart ( ));
605
+ .waitTimeSeconds (toInt ( pollTimeout .toSeconds () ));
606
606
if (additionalHeaders .containsKey (SqsHeaders .SQS_VISIBILITY_TIMEOUT_HEADER )) {
607
607
builder .visibilityTimeout (
608
- getValueAs (additionalHeaders , SqsHeaders .SQS_VISIBILITY_TIMEOUT_HEADER , Duration .class )
609
- .toSecondsPart ( ));
608
+ toInt ( getValueAs (additionalHeaders , SqsHeaders .SQS_VISIBILITY_TIMEOUT_HEADER , Duration .class )
609
+ .toSeconds () ));
610
610
}
611
611
if (additionalHeaders .containsKey (SqsHeaders .SQS_RECEIVE_REQUEST_ATTEMPT_ID_HEADER )) {
612
612
builder .receiveRequestAttemptId (
@@ -616,6 +616,15 @@ private ReceiveMessageRequest doCreateReceiveMessageRequest(Duration pollTimeout
616
616
return builder .build ();
617
617
}
618
618
619
+ // Convert a long value to an int. Values larger than Integer.MAX_VALUE are set to Integer.MAX_VALUE
620
+ private int toInt (long longValue ) {
621
+ if (longValue > Integer .MAX_VALUE ) {
622
+ return Integer .MAX_VALUE ;
623
+ }
624
+
625
+ return (int ) longValue ;
626
+ }
627
+
619
628
private <V > V getValueAs (Map <String , Object > headers , String headerName , Class <V > valueClass ) {
620
629
return valueClass .cast (headers .get (headerName ));
621
630
}
0 commit comments