Ales Dolecek created CAMEL-6499:
-----------------------------------
Summary: Copy of GenericFileMessage returns NULL from toString
Key: CAMEL-6499
URL: https://issues.apache.org/jira/browse/CAMEL-6499
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.11.0
Reporter: Ales Dolecek
CAMEL-3060 changed GenericFileMessage#toString to output just file name instead
of it's content. However copies of message do not have file field set and thus
return null from toString method. In my application actually all routed
messages are copies and thus I see just "null" in my logs files.
The copies are created by constructor:
org.apache.camel.impl.DefaultUnitOfWork.DefaultUnitOfWork(Exchange exchange,
Logger logger). The code seems like "dirty hack" in sense that it treats
JmsMessage specially and all other messages handle by:
this.originalInMessage = exchange.getIn().copy();
There is no override of copy() method (provided by MessageSupport) in
GenericFileMessage. This leads to lose of value of the internal file property.
---
I'm not sure if the problem missing override of copy() method or if it is
pretty "legal" to have GenericFileMessage without file.
I'm, on the other hand, pretty sure that returning NULL from toString() is BAD
practise. The method should stick to java.lang.Object behavior if it does not
know what to print:
@Override
public String toString() {
// only output the filename as body can be big
if (file != null) {
return file.getFileName();
}
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
Ales
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira