You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2016/03/10 17:23:40 UTC

[jira] [Resolved] (CAMEL-9694) StreamCaching does not work with FTP2-components localWorkingDirectory

     [ https://issues.apache.org/jira/browse/CAMEL-9694?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-9694.
--------------------------------
    Resolution: Won't Fix

> StreamCaching does not work with FTP2-components localWorkingDirectory
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-9694
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9694
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.16.2
>            Reporter: Jostein Gogstad
>
> From the [FTP2-components documentation|https://camel.apache.org/ftp2.html] we read that the {{localWorkDirectory}} attribute can be used to download the file up-front. Stream caching does not work in conjunction with this option.
> {code:java|title=StreamCachingTest.java}
> import org.apache.camel.EndpointInject;
> import org.apache.camel.Exchange;
> import org.apache.camel.LoggingLevel;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.apache.commons.io.IOUtils;
> import org.junit.Test;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> import java.io.IOException;
> import java.io.InputStream;
> public class StreamCachingTest extends CamelTestSupport {
>     public static final String URI_END_OF_ROUTE = "mock:end_of_route";
>     @EndpointInject(uri = URI_END_OF_ROUTE)
>     private MockEndpoint endOfRoute;
>     @Override
>     public boolean isUseAdviceWith() {
>         return true;
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 context.setStreamCaching(true);
>                 from("ftp://192.168.99.100/outbox?passiveMode=true&localWorkDirectory=/tmp&username=docker&password=docker&noop=true")
>                     .wireTap("direct:mydirect");
>                 from("direct:mydirect")
>                     .process(new Processor() {
>                         @Override
>                         public void process(Exchange exchange) throws Exception {
>                             Thread.sleep(3000);
>                             String s = IOUtils.toString(exchange.getIn().getBody(InputStream.class));
>                             log.info("Consumed " + s.substring(0, 5));
>                         }
>                     })
>                     .to(URI_END_OF_ROUTE);
>             }
>         };
>     }
>     @Test
>     public void stream_caching_with_spring() throws Exception {
>         endOfRoute.expectedMessageCount(1);
>         context.start();
>         endOfRoute.assertIsSatisfied();
>     }
> }
> {code}
> It fails with:
> {code:none}
> Caused by: java.io.FileNotFoundException: /tmp/FOO.DAT (The system cannot find the file specified)
> 	at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_60]
> 	at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_60]
> 	at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_60]
> 	at org.apache.camel.converter.IOConverter.toInputStream(IOConverter.java:78) ~[camel-core-2.16.2.jar:2.16.2]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60]
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60]
> 	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60]
> 	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1243) ~[camel-core-2.16.2.jar:2.16.2]
> 	at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59) ~[camel-core-2.16.2.jar:2.16.2]
> 	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:293) ~[camel-core-2.16.2.jar:2.16.2]
> 	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:120) ~[camel-core-2.16.2.jar:2.16.2]
> 	... 32 more
> {code}
> Looks like the stream caching isn't invoked at all.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)