[
https://issues.apache.org/jira/browse/CAMEL-3277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037628#comment-13037628
]
Fernando Racca commented on CAMEL-3277:
---------------------------------------
Managed to reproduce this issue with Camel 2.7.0
A simple HTTP request followed by an XPath expression in a bean.
public class PricesParser {
public static void main(String args[]) throws Exception {
// create CamelContext
CamelContext context = new DefaultCamelContext();
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
public void configure() {
from("http://url").bean(new MyBean()).to("file:target/prices");
// start the route and let it do its work
context.start();
Thread.sleep(3000);
// stop the CamelContext
context.stop();
}
public static class MyBean {
public String parse(@XPath("//div[@id='prices']") String prices) {
return prices;
}
}
However, all converters seem to have loaded:
.........
[ main] AnnotationTypeConverterLoader INFO Found 4
packages with 15 @Converter classes to load
[ main] DefaultTypeConverter INFO Loaded
157 type converters in 0.515 seconds
main] DefaultCamelContext INFO Route: route1 started and consuming
from: Endpoint[http://url]
[ main] DefaultCamelContext INFO Total 1
routes, of which 1 is started.
[ main] DefaultCamelContext INFO Apache
Camel 2.7.0 (CamelContext: camel-1) started in 1.914 seconds
[url] route1 INFO before
[ main] DefaultCamelContext INFO Apache
Camel 2.7.0 (CamelContext:camel-1) is shutting down
[ main] DefaultShutdownStrategy INFO Starting
to graceful shutdown 1 routes (timeout 300 seconds)
[ main] DefaultExecutorServiceStrategy DEBUG Created
new single thread pool for source:
org.apache.camel.impl.DefaultShutdownStrategy@64c5e2cf with name: ShutdownTask.
-> java.util.concurrent.Executors$FinalizableDelegatedExecutorService@95d0a50
[el-1) thread #1 - ShutdownTask] DefaultShutdownStrategy DEBUG There are
1 routes to shutdown
[el-1) thread #1 - ShutdownTask] DefaultShutdownStrategy DEBUG Suspend
complete for: Consumer[http://url]
[el-1) thread #1 - ShutdownTask] DefaultShutdownStrategy INFO Route:
route1 suspended and shutdown deferred, was consuming from: Endpoint[http://url]
Unit tests that don't read from that http url seem to work fine.
Should i open a new jira for this?
> Threading issue which lets converter loading abort
> --------------------------------------------------
>
> Key: CAMEL-3277
> URL: https://issues.apache.org/jira/browse/CAMEL-3277
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.4.0
> Environment: SMX 4
> Reporter: Lars Heinemann
> Assignee: Claus Ibsen
> Fix For: 2.6.0
>
> Attachments: patch.diff
>
>
> The type converter loading is not threadsafe and fails sometimes. That will
> end up with around 17 type converters loaded only which will probably let
> your camel routes fail with conversion errors like:
> {noformat}
> 07:04:31,112 | ERROR | qtp25205731-2783 | DefaultErrorHandler |
> rg.apache.camel.processor.Logger 248 | 68 - org.apache.camel.camel-core -
> 2.4.0.fuse-00-00 | Failed delivery for exchangeId:
> 53e23457-5551-4487-9fc4-87dd33687f0b. Exhausted after delivery attempt: 1
> caught: java.lang.ClassCastException:
> org.apache.camel.converter.stream.InputStreamCache cannot be cast to
> org.w3c.dom.Node
> java.lang.ClassCastException:
> org.apache.camel.converter.stream.InputStreamCache cannot be cast to
> org.w3c.dom.Node
> at
> com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:116)[:1.6.0_17]
> at
> com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:98)[:1.6.0_17]
> at
> com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:180)[:1.6.0_17]
> at
> org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:598)[68:org.apache.camel.camel-core:2.4.0.fuse-00-00]
> at
> org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:570)[68:org.apache.camel.camel-core:2.4.0.fuse-00-00]
> at
> org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:122)[68:org.apache.camel.camel-core:2.4.0.fuse-00-00]
> {noformat}
> Tracking the issue down showed that several type converter loaders share the
> same registry object and fail to load all converters every once a while. That
> can be fixed by making the load method synchronized...see attached patch.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira