Darren Coleman created CAMEL-19105:
--------------------------------------
Summary: camel-language: contentCache option bypassed when loading
script over http
Key: CAMEL-19105
URL: https://issues.apache.org/jira/browse/CAMEL-19105
Project: Camel
Issue Type: Bug
Components: camel-language
Affects Versions: 3.20.1
Reporter: Darren Coleman
I set up a route to load a simple script via an HTTP endpoint and, as far as I
can tell, the contentCache option isn't checked. When calling the endpoint
{{{}language:simple:[http://localhost:8080/simple]{}}}, the
{{LanguageProducer.process()}} method calls directly on
{{ResourceHelper.resolveMandatoryResourceAsInputStream()}} ([line
79|https://github.com/apache/camel/blob/camel-3.20.1/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java#L79])
instead of calling on the endpoint's {{getResourceAsInputStream()}} method
that handles the caching.
The following code sets up a REST endpoint to return a simple script, and the
language endpoint is called twice. I would expect the the REST route to log
output for the first call only.
{code:java}
public class CamelLanguageHttpTest {
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
restConfiguration().component("netty-http")
.host("localhost").port(8080);
rest("/")
.get("simple").to("direct:simple");
from("direct:simple")
.transform()
.constant("Hello ${body}!").to("stream:out");
}
});
context.start();
ProducerTemplate producer = context.createProducerTemplate();
String endpoint = "language:simple:http://localhost:8080/simple";
String result = producer.requestBody(endpoint, "SimpleHttp", String.class);
producer.requestBody(endpoint, "SimpleHttp", String.class);
context.stop();
context.close();
}
}
// Output:
// Hello ${body}!
// Hello ${body}!
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)