You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Darren Coleman (Jira)" <ji...@apache.org> on 2023/03/02 10:09:00 UTC
[jira] [Commented] (CAMEL-19105) camel-language: contentCache option bypassed when loading script over http
[ https://issues.apache.org/jira/browse/CAMEL-19105?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17695627#comment-17695627 ]
Darren Coleman commented on CAMEL-19105:
----------------------------------------
Ah thanks Claus, that worked a treat!
> 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
> Assignee: Claus Ibsen
> Priority: Minor
>
> 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)