1 Reply Latest reply on Feb 1, 2011 9:37 PM by kcbabo

    Annotations cannot terminate pipeline with null return

    ben.wright

      I've noticed a behavior that differs when using AbstractActionLifecycle and Annotations. 

       

      I've been using both and I prefer Annotations as the class files written are generally quicker to create and easier to understand / maintain.

       

      However, I've run into a few glitches - one is the inability to specify a body location on the ConfigTree for parameters through annotation, but I believe that's already being looked into and isn't a big deal.

       

      Another one I discovered recently is that the behavior when returning a null Message is drastically different between Annotations and "regular" actions.

       

      when using a method with a return type of "Message"

       

      i.e.

       

      public Message process(Message message) {

           return null;

      }

       

      returning a null value will terminate processing of the message on a "regular" action, while performing this return on an annotated process method (through the org.jboss.soa.esb.listeners.message.BeanContainerAction class) results in continuing to the next action in the pipeline immediately.

       

      The code that results in this behavior is: (from BeanContainerAction process method)

       

              if(processResult instanceof Message) {

                  return (Message) processResult;

              } else if(processResult != null) {

                  try {

                      payloadProxy.setPayload(message, processResult);

                  } catch (MessageDeliverException e) {

                      throw new ActionProcessingException("Error injecting 'out' payload into ESB message.", e);

                  }

              }

       

              return message;

       

      as can be seen, if the return is null then the original message rather than the null will be returned by BeanContainerAction.

       

      Is this the intended behavior of annotated action classes, or should this be entered as a bug?

       

      Notably, the 'fix' is fairly simple: (this could be more efficiently with the surrounding code)

       

              if(processResult == null && Message.class.isAssignableFrom(processMethod.getReturnType())) {

                  return null;

              }