You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/07/11 12:12:40 UTC

[3/3] git commit: CAMEL-7595: camel-jdbc should preserve headers first so new headers can be updated from the jdbc result such as update count.

CAMEL-7595: camel-jdbc should preserve headers first so new headers can be updated from the jdbc result such as update count.

Conflicts:
	components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java


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

Branch: refs/heads/camel-2.12.x
Commit: b9b6ad411d3200e6af1a744daca3f5b5a86e97c6
Parents: 97f984c
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jul 11 12:10:18 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 11 12:12:27 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/jdbc/JdbcProducer.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b9b6ad41/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index d573587..0446fb7 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -67,8 +67,6 @@ public class JdbcProducer extends DefaultProducer {
         } else {
             processingSqlWithoutSettingAutoCommit(exchange);
         }
-        // populate headers
-        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
     }
 
     private void processingSqlBySettingAutoCommit(Exchange exchange) throws Exception {
@@ -141,6 +139,9 @@ public class JdbcProducer extends DefaultProducer {
                 setResultSet(exchange, rs);
             } else {
                 int updateCount = ps.getUpdateCount();
+                // preserve headers
+                exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
+                // and then set the new header
                 exchange.getOut().setHeader(JdbcConstants.JDBC_UPDATE_COUNT, updateCount);
             }
         } finally {
@@ -262,6 +263,9 @@ public class JdbcProducer extends DefaultProducer {
      * Sets the result from the ResultSet to the Exchange as its OUT body.
      */
     protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
+        // preserve headers
+        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
+
         JdbcOutputType outputType = getEndpoint().getOutputType();
 
         if (outputType == JdbcOutputType.SelectList) {