Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16912

AbstractMethodMessageHandler does not rethrow Errors


    • Last commented by a User:


      We're using Spring Cloud AWS to receive messages from SQS.

      Now, due to a bug, one of our services threw an OutOfMemoryError.

      Having a redrive policy to a dead-letter queue set on the SQS queue, I assumed that with deletion policy NO_REDRIVE, the messages would get returned to the queue.

      But that is not happening, as the AbstractMethodMessageHandler, that re-throws exceptions in case they occur, does not do that with errors (to be more precise, with all Throwables that are not of type Exception):

      try {
      catch (Exception ex) {
      	processHandlerMethodException(handlerMethod, ex, message);
      catch (Throwable ex) {
      	if (logger.isErrorEnabled()) {
      		logger.error("Error while processing message " + message, ex);

      That has the effect that the SimpleMessageListenerContainer of Spring Cloud AWS Messaging assumes the execution finished without any error, and hence deletes the message from the queue:

       try {
      } catch (MessagingException messagingException) {
              applyDeletionPolicyOnError(receiptHandle, messagingException);

      executeMessage() returns silently, as the throwable was swallowed, and hence, applyDeletionPolicy*OnSuccess*() is executed next.

      In case of an Exception, it would execute applyDeletionPolicy*OnError*, but not in case of an error.

      Question: Is the Spring Framework violating the contract, by swallowing the Error? IMHO it should be re-thrown, just like ordinary Exceptions are.

      Or is the SimpleMessageListenerContainer wrong to assume that if executeMessage has returned normally, the processing went fine without any problem? If yes, how can it figure out that an error has occurred?


          Issue Links



              • Assignee:
                juergen.hoeller Juergen Hoeller
                BstBln Bernhard Streit
                Last updater:
                Stéphane Nicoll
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created:
                  Days since last comment:
                  23 weeks, 1 day ago