Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Complete
-
None
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<?>.