On Thu, Aug 6, 2009 at 3:44 PM, _Jens<[email protected]> wrote: > > Hi, > > What is the expected behavior in Camel 2.0 if no type converter is found for > a conversion? According to the http://camel.apache.org/type-converter.html > documentation starting with Camel 1.5 a NoTypeConversionAvailableException > should be thrown. This seems not to be the case in Camel 2.0 anymore. I > wrote this little test: > > �...@test(expected = NoTypeConversionAvailableException.class) > public void testUnknownConversion() { > CamelContext camelContext = new DefaultCamelContext(); > DefaultExchange exchange = new DefaultExchange(camelContext); > exchange.getIn().setBody(new Thread()); > exchange.getIn().getBody(Date.class); > } > > It works on 1.6, but fails in 2.0, because getBody() returns null. Was this > changed again?
Yes in 2.0 there is a getMandatoryBody() to use in cases where you want a type converter to exist. The getBody() will just return null if it could not be converted to expected type. This is the idiom moving forward there are other places where there is a regular getter and then a mandatory counter part as well. > > Thanks, > Jens > -- > View this message in context: > http://www.nabble.com/Type-Converters-in-Camel-2.0-tp24846895p24846895.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
