You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Bohdan Zhezlo (JIRA)" <ji...@apache.org> on 2015/09/22 15:32:04 UTC

[jira] [Updated] (CAMEL-9152) Camel streaming component doesn't close a stream when last exchange is not passed to the endpoint

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

Bohdan Zhezlo updated CAMEL-9152:
---------------------------------
    Description: 
Here is sample test which reproduces the problem:

{code:java}
route.from("direct:foo")
    .split().tokenize("\n").streaming()
    .choice()
        .when(body().isEqualTo(9))
        .stop()
     .otherwise()
         .to("stream:file?fileName=streaming.txt&closeOnDone=true")
     .endChoice();

@Produce(uri = "direct:foo")
protected ProducerTemplate template;

StringBuilder builder = new StringBuilder();
for(int i = 0; i < 10; i++) {
   builder.append(i);
   builder.append("\n");
}

template.sendBody(builder.toString());

File file = new File("streaming.txt");
boolean exists = file.exists();
boolean deleted = file.delete();
{code}

After running sample test 'deleted' will be false and file is present on file system, which indicates that the file stream was not closed.

If I modify condition in the route so that no exchanges get skipped (or if I skip any exchange except the last one) then file is successfully deleted.

  was:
Here is sample test which reproduces the problem:

{code:java}
route.from("direct:foo")
                        .split().tokenize("\n").streaming()
                        .choice()
                            .when(body().isEqualTo(9))
                            .stop()
                        .otherwise()
                            .to("stream:file?fileName=streaming.txt&closeOnDone=true")
                        .endChoice();

@Produce(uri = "direct:foo")
protected ProducerTemplate template;

StringBuilder builder = new StringBuilder();
for(int i = 0; i < 10; i++) {
            builder.append(i);
            builder.append("\n");
}

template.sendBody(builder.toString());

File file = new File("streaming.txt");
boolean exists = file.exists();
boolean deleted = file.delete();
{code}

After running sample test 'deleted' will be false and file is present on file system, which indicates that the file stream was not closed.

If I modify condition in the route so that no exchanges get skipped (or if I skip any exchange except the last one) then file is successfully deleted.


> Camel streaming component doesn't close a stream when last exchange is not passed to the endpoint
> -------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-9152
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9152
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-stream
>    Affects Versions: 2.14.1
>            Reporter: Bohdan Zhezlo
>
> Here is sample test which reproduces the problem:
> {code:java}
> route.from("direct:foo")
>     .split().tokenize("\n").streaming()
>     .choice()
>         .when(body().isEqualTo(9))
>         .stop()
>      .otherwise()
>          .to("stream:file?fileName=streaming.txt&closeOnDone=true")
>      .endChoice();
> @Produce(uri = "direct:foo")
> protected ProducerTemplate template;
> StringBuilder builder = new StringBuilder();
> for(int i = 0; i < 10; i++) {
>    builder.append(i);
>    builder.append("\n");
> }
> template.sendBody(builder.toString());
> File file = new File("streaming.txt");
> boolean exists = file.exists();
> boolean deleted = file.delete();
> {code}
> After running sample test 'deleted' will be false and file is present on file system, which indicates that the file stream was not closed.
> If I modify condition in the route so that no exchanges get skipped (or if I skip any exchange except the last one) then file is successfully deleted.



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