You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Chris Watts (JIRA)" <ji...@apache.org> on 2013/01/31 01:25:14 UTC
[jira] [Created] (CAMEL-6025) NumberFormatException when using File
over JMS
Chris Watts created CAMEL-6025:
----------------------------------
Summary: NumberFormatException when using File over JMS
Key: CAMEL-6025
URL: https://issues.apache.org/jira/browse/CAMEL-6025
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.10.2
Reporter: Chris Watts
When using the FileConsumer to send a file to a JMS queue which is then consumed by the FileProducer I get the following error:
{noformat}
11:03:22,778 DEBUG [Camel (camel) thread #1 - JmsConsumer[queue1]] (MarkerIgnoringBase.java:72) - Failed delivery for (MessageId: queue_queue1_ID_xxxxxxxxx-1911-1359590595842-3_4_1_1_1 on ExchangeId: ID-xxxxxxxxx-1910-1359590595467-0-10). On delivery attempt: 0 caught: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.lang.Long with value Thu Jan 31 11:03:22 EST 2013 due java.lang.NumberFormatException: For input string: "Thu Jan 31 11:03:22 EST 2013"{noformat}
This is due to a Date being converted to a String when sending over JMS.
Propose that the following line in Generic file be changed from:
{code} if (getLastModified() > 0) {
message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
}{code}
To:{code} if (getLastModified() > 0) {
message.setHeader(Exchange.FILE_LAST_MODIFIED, getLastModified());
}{code}
As FileOperations can use it:
{code} private void keepLastModified(Exchange exchange, File file) {
if (endpoint.isKeepLastModified()) {
Long last;
Date date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
if (date != null) {
last = date.getTime();
} else {
// fallback and try a long
last = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
}
if (last != null) {
boolean result = file.setLastModified(last);
if (LOG.isTraceEnabled()) {
LOG.trace("Keeping last modified timestamp: {} on file: {} with result: {}", new Object[]{last, file, result});
}
}
}
}{code}
--
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