camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8995: camel-restlet - Should defer UoW done until after writing response
Date Wed, 22 Jul 2015 04:57:06 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 2f29f5d9a -> a3b216df5
  refs/heads/master a6793490e -> a01d49f80


CAMEL-8995: camel-restlet - Should defer UoW done until after writing response


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a01d49f8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a01d49f8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a01d49f8

Branch: refs/heads/master
Commit: a01d49f8092739ae09a256c8f45c426bcdb5cef7
Parents: a679349
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jul 22 07:03:31 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jul 22 07:03:31 2015 +0200

----------------------------------------------------------------------
 .../camel/component/restlet/RestletConsumer.java   | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a01d49f8/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
index fd39ac8..fa1f847 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.restlet;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultConsumer;
 import org.restlet.Request;
 import org.restlet.Response;
@@ -50,10 +49,16 @@ public class RestletConsumer extends DefaultConsumer {
         return new Restlet() {
             @Override
             public void handle(Request request, Response response) {
+                // must call super according to restlet documentation
+                super.handle(request, response);
+
                 LOG.debug("Consumer restlet handle request method: {}", request.getMethod());
 
+                Exchange exchange = null;
                 try {
-                    Exchange exchange = getEndpoint().createExchange();
+                    // we want to handle the UoW
+                    exchange = getEndpoint().createExchange();
+                    createUoW(exchange);
 
                     RestletBinding binding = getEndpoint().getRestletBinding();
                     binding.populateExchangeFromRestletRequest(request, response, exchange);
@@ -65,8 +70,12 @@ public class RestletConsumer extends DefaultConsumer {
                     }
                     binding.populateRestletResponseFromExchange(exchange, response);
 
-                } catch (Exception e) {
-                    throw new RuntimeCamelException("Cannot process request", e);
+                } catch (Throwable e) {
+                    getExceptionHandler().handleException("Error processing request", exchange,
e);
+                } finally {
+                    if (exchange != null) {
+                        doneUoW(exchange);
+                    }
                 }
             }
         };


Mime
View raw message