Krzysztof Mackowiak created CAMEL-18816:
-------------------------------------------
Summary: camel-ahc component crashes when a traffic starts too
early
Key: CAMEL-18816
URL: https://issues.apache.org/jira/browse/CAMEL-18816
Project: Camel
Issue Type: Bug
Components: camel-ahc
Affects Versions: 3.18.4
Reporter: Krzysztof Mackowiak
Attachments: camel-ahc-bug.patch
Unfortunately it looks that when traffic to camel-ahc component starts to early
it crashes with an exception:
{code:java}
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for
endpoint: ahc://http://localhost:59729/foo.
Reason: java.lang.IllegalArgumentException: AsyncHttpClient must be specified
on: ahc://http://localhost:59729/foo
at
org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:164)
at
org.apache.camel.processor.RecipientListProcessor.doCreateProcessorExchangePairs(RecipientListProcessor.java:270)
at
org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:246)
at
org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:295)
at org.apache.camel.processor.RecipientList.process(RecipientList.java:175)
at org.apache.camel.processor.Pipeline$PipelineTask.run(Pipeline.java:106)
at
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:189)
at
org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:61)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:182)
at
org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:399)
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210)
at
org.apache.camel.component.timer.TimerConsumer$2.run(TimerConsumer.java:118)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: AsyncHttpClient must be
specified on: ahc://http://localhost:59729/foo
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:176)
at
org.apache.camel.component.ahc.AhcEndpoint.createProducer(AhcEndpoint.java:94)
at
org.apache.camel.support.DefaultEndpoint.createAsyncProducer(DefaultEndpoint.java:200)
at
org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:237)
at
org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:216)
at org.apache.camel.support.cache.ServicePool.acquire(ServicePool.java:112)
at
org.apache.camel.support.cache.ProducerServicePool.acquire(ProducerServicePool.java:28)
at
org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:149)
... 14 common frames omitted
{code}
It causes that all traffic to camel-ahc endpoint is failing. It happens in my
application for routes that take messages from JMS queue and sent it to HTTP
(using camel-ahc component).
Here is a test that reproduces a problem:
{code:java}
public class AhcRecipientListTest extends BaseAhcTest {
@Test
public void testRecipientListCalledBeforeComponentStarted() throws
Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("Hello");
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://foo?delay=-1&?repeatCount=1")
.recipientList(constant(getAhcEndpointUri()))
.to("mock:result");
from(getTestServerEndpointUri())
.transform(constant("Hello"));
}
};
}
} {code}
I've prepared a patch with another 2 tests and a possible bugfix. The bugfix is
based on a solution from HttpEnpoint/HttpProducer.
The bug was discovered in version 3.18.4, but it looks that it was present for
a long time.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)