camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CAMEL-2935) Broken failure reporting via DefaultProucerTemplate.asyncCallback and Synchronization.onFailure
Date Sat, 10 Jul 2010 14:27:54 GMT

    [ https://issues.apache.org/activemq/browse/CAMEL-2935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=60579#action_60579
] 

Claus Ibsen edited comment on CAMEL-2935 at 7/10/10 10:27 AM:
--------------------------------------------------------------

I have to fix some unit tests which was relying on the old behavior of {{template.send(Exchange)}}
and {{template.request(Exchange)}} not throwing an exception, which wasn't entirely covered
by the first fix. Now with all the template methods fixed they surface some tests which now
fails due to the tighten contract.


      was (Author: davsclaus):
    I have to fix some unit tests which was relying on the old behavior of {{template.send(Exchange)}}
and {{template.request(Exchange)}} not throwing an exception.


  
> Broken failure reporting via DefaultProucerTemplate.asyncCallback and Synchronization.onFailure
> -----------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-2935
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2935
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.3.0
>            Reporter: Martin Krasser
>             Fix For: 2.4.0
>
>         Attachments: on-failure.patch
>
>
> The recent change in {{ProducerCache.send}}
> {code:java|title=ProducerCache.java}
>     public void send(Endpoint endpoint, Exchange exchange) {
>         try {
>             sendExchange(endpoint, null, null, exchange);
>             // RECENT CHANGE HERE:
>             // ensure that CamelExecutionException is always thrown
>             if (exchange.getException() != null) {
>                 exchange.setException(wrapCamelExecutionException(exchange, exchange.getException()));
>             }
>         } catch (Exception e) {
>             throw wrapCamelExecutionException(exchange, e);
>         }
>     }
> {code}
> that throws a {{CamelExecutionException}} if {{exchange.getException}} is not null, makes
it impossible for {{DefaultProducerTemplate.asyncCallback}} to report failures (other than
fault messages) asynchronously via {{Synchronization.onFailure}}
> {code:java|title=DefaultProducerTemplate.java}
>     public Future<Exchange> asyncCallback(final Endpoint endpoint, final Exchange
exchange, final Synchronization onCompletion) {
>         Callable<Exchange> task = new Callable<Exchange>() {
>             public Exchange call() throws Exception {
>                 // FIXME: exception is thrown in Camel 2.4 where a normal return with
answer.getException != null was done in Camel 2.3
>                 Exchange answer = send(endpoint, exchange);
>                 if (answer.isFailed()) {
>                     onCompletion.onFailure(answer);
>                 } else {
>                     // ...
>                 }
>                 return answer;
>             }
>         };
>         // ...
>     }
> {code}
> This was working in Camel 2.3 (but unfortunately there wasn't any test case for it).
I attached a patch for {{DefaultProducerTemplateAsyncTest}} that demonstrates the problem.
I didn't commit a fix yet because I'm unsure at the moment about the best way to fix that.
Of course I tried a naive fix in the DefaultProducerTemplate.asyncCallback methods which causes
the test (in the patch) to pass but I'd like to hear other opinions before I continue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message