@@ -438,22 +438,22 @@ private void submitEventsAndEndpoint(final JSONArray eventArray,
438438 } catch (final AmazonServiceException amazonServiceException ) {
439439 // This is service level exception, we also have item level exception.
440440 log .error ("AmazonServiceException occurred during send of put event " , amazonServiceException );
441- final String errorCode = amazonServiceException .getErrorCode ();
441+ final int statusCode = amazonServiceException .getStatusCode ();
442442
443443 // If the error is not a retryable error, delete the events from the local database.
444444 // Else if the error is a retryable error, keep the events in the local database.
445- if (isRetryable (errorCode )) {
445+ if (isRetryable (statusCode )) {
446446 log .error (
447447 String .format ("AmazonServiceException: Unable to successfully deliver events to server. " +
448448 "Events will be saved, error is likely recoverable. " +
449449 "Response Status code: %s, Response Error Code: %s" ,
450- amazonServiceException . getStatusCode () , amazonServiceException .getErrorCode ()),
450+ statusCode , amazonServiceException .getErrorCode ()),
451451 amazonServiceException );
452452 batchIdsAndSizeToDelete .clear ();
453453 } else {
454454 log .error (
455455 String .format (Locale .getDefault (), "Failed to submit events to EventService: statusCode: " +
456- amazonServiceException . getStatusCode () + " errorCode: " , errorCode ),
456+ statusCode + " errorCode: " , amazonServiceException . getErrorCode () ),
457457 amazonServiceException );
458458 log .error (
459459 String .format (Locale .getDefault (), "Failed submission of %d events, events will be " +
@@ -531,7 +531,7 @@ private void processEventsResponse(final JSONArray eventArray,
531531 // so the event does not get deleted from the local database.
532532 if (responseMessage .getMessage ().equalsIgnoreCase ("Accepted" )) {
533533 log .info (String .format ("Successful submit event with event id %s" , eventId ));
534- } else if (isRetryable (responseMessage .getMessage ())) {
534+ } else if (isRetryable (responseMessage .getStatusCode ())) {
535535 log .warn (String .format ("Unable to successfully deliver event to server. " +
536536 "Event will be saved. Event id %s" , eventId ));
537537 batchIdsAndSizeToDelete .remove (eventArray .getJSONObject (i ).getInt (DATABASE_ID_KEY ));
@@ -548,13 +548,8 @@ private void processEventsResponse(final JSONArray eventArray,
548548 }
549549 }
550550
551- private boolean isRetryable (String responseCode ) {
552- if (responseCode .equalsIgnoreCase ("ValidationException" ) ||
553- responseCode .equalsIgnoreCase ("SerializationException" ) ||
554- responseCode .equalsIgnoreCase ("BadRequestException" )) {
555- return false ;
556- }
557- return true ;
551+ private boolean isRetryable (int httpCode ) {
552+ return httpCode >= 500 && httpCode <= 599 ;
558553 }
559554
560555 private boolean isClientExceptionRetryable (Throwable amazonClientException ) {
0 commit comments