Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-4197

MessagingMethodInvokerHelper Error Message Improvement

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 5.0.M2, 4.3.7
    • Component/s: Core
    • Labels:

      Description

      The following:

      @Router(inputChannel = "routingChannel")
      public String route(List<?> payload) {
      	if (payload.size() == 0) {
      		return null;
      	}
      	if (payload.get(0) instanceof Integer) {
      		return "integerChannel";
      	}
      	else {
      		return "stringChannel";
      	}
      }
      

      Results in:

      Exception in thread "main" org.springframework.messaging.MessageHandlingException: nested exception is org.springframework.expression.AccessException: Unable to access property 'messages' through getter method
      ...
      Caused by: java.lang.IllegalStateException: Invalid method parameter for messages: was expecting a single payload.

      public String route(List<Object> payload) {
          ...
      }
      

      Works fine.

      The issue is that List<?> matches dummyMessages and is interpreted to be a collection of Message<?>, so the invocation expression is #target.route(messages).

      If possible, we should attempt to determine that the element is to process a simple payload; if that's not possible, we should at least log a more meaningful error, or log a warning to tell the user to use Collection<Object> instead of Collection<?>.

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            grussell Gary Russell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: