Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending a message with an empty ArrayList to a splitter provides the ArrayList to the outputChannel [INT-1442] #5439

Closed
spring-operator opened this issue Sep 12, 2010 · 8 comments
Milestone

Comments

@spring-operator
Copy link
Contributor

spring-operator commented Sep 12, 2010

Jettro Coenradie opened INT-1442 and commented

The implementation for Splitters on this topic must have changed from M3 to M7. When providing an empty ArrayList object to a splitter, in M3 no message was passed to the outputChannel. With the M7 release, an ArrayList object is send to the outputChannel.

Easy way to verify is the Cafe sample. Remove the orderlines from the order and you see the message.

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Field or property 'iced' cannot be found on object of type 'java.util.ArrayList'
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:206)
	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:71)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
	at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:135)
	at org.springframework.expression.spel.ast.Ternary.getValueInternal(Ternary.java:47)
	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
	at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:100)
	at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:74)
	... 34 more

For us this is a serious problem,


Affects: 2.0 M7

Sub-tasks:

@spring-operator
Copy link
Contributor Author

Jettro Coenradie commented

This might help: I created a Unit test to show the problem. The test was created in : SplitterIntegrationTests

@Test
public void splitMessageWithEmptyCollectionPayload() throws Exception {
	List<String> payload = new ArrayList<String>();
	Message<List<String>> message = MessageBuilder.withPayload(payload).build();
	QueueChannel replyChannel = new QueueChannel();
	DefaultMessageSplitter splitter = new DefaultMessageSplitter();
	splitter.setOutputChannel(replyChannel);
	splitter.handleMessage(message);
	List<Message<?>> replies = replyChannel.clear();
	System.out.println("**********" + replies.get(0).getPayload().getClass());
	assertEquals(0, replies.size());
}

@spring-operator
Copy link
Contributor Author

Iwein Fuld commented

I've found the problem and I've got a fix. I'll push it once I've aligned with Oleg.

@spring-operator
Copy link
Contributor Author

Iwein Fuld commented

One question that we need to resolve before closing this issue is what the actual expected behavior is. My fix (in the nightly tomorrow) is splitting the empty message into zero reply messages.

If you can think of any reason why not generating a reply in this case is a problem, please speak up.

@spring-operator
Copy link
Contributor Author

Mark Fisher commented

I think no reply is the correct behavior. For consistency's sake, I think that also means we should add namespace support for the 'requires-reply' value for any Splitter. The general idea is that any component that might not produce any reply even if one is expected (e.g. by a waiting Gateway upstream) so that an immediate Exception can be thrown in such cases rather than waiting for a timeout. This is very similar to the case where a Service Activator returns NULL, and it's also somewhat similar to the "throw-exception-on-rejection" flag for a Filter. If others agree, then we can create a separate issue for exposing that namespace attribute.

@spring-operator
Copy link
Contributor Author

Oleg Zhurakousky commented

I agree and that is what I was thinking. Empty collection = no reply, since nothing was sent downstream. However there has to be an option that explicitly notifies the caller that reply isn't coming and yes 'requires-reply' will be consistent with SA

@spring-operator
Copy link
Contributor Author

Jettro Coenradie commented

I thinking an empty reply is also fine. The actual result is Thatcher the. Message was passed and IT was returned withouten errors. I would expect simular behavior for à collection with items as for à collection without items.

@spring-operator
Copy link
Contributor Author

Jettro Coenradie commented

Sorry, my previous comment reads a bit weird. Tries to type it on my iPad, not good when it is on the Dutch language.

I thinking an empty reply is also fine. The actual result is that the message was passed and it was returned withouten errors. I would expect simular behavior for a collection with items as for a collection without items. Although I do understand what Oleg is saying as well. I think that I did receive a reply message in the past.

@spring-operator
Copy link
Contributor Author

Oleg Zhurakousky commented

Fixed with the following behavior.
If result of the split is:

  • NULL
  • Empty Collection
  • Empty Array

no reply message will be sent to the output-channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant