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 2019/12/30 09:11:20 UTC

[camel] branch camel-3.0.x updated (7c4f569 -> 113e814)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 7c4f569  CAMEL-14323 - XMPP room with password disconnect after bootup, thanks Tapio Piironen for the patch
     new 6292b09  CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the patch.
     new 868eb80  CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the 2nd patch.
     new c95d049  camel-aws-lambda: Close FileInputStreams in LambdaProducer#createFunction because com.amazonaws.util.IOUtils#toByteArray requires the client to close the InputStream.
     new e039a8f  camel-google-bigquery: Close the FileInputStream in GoogleBigQueryConnectionFactory#createFromFile
     new 113e814  Fix build broken by d0d2df571400e87f130866c3eced085504b7e125

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/aws/lambda/LambdaProducer.java | 10 +--
 .../bigquery/GoogleBigQueryConnectionFactory.java  | 12 ++--
 .../component/jt400/Jt400DataQueueProducer.java    | 26 +++----
 .../component/jt400/Jt400DataQueueService.java     | 10 ++-
 .../camel/component/jt400/Jt400Endpoint.java       |  6 --
 .../component/jt400/Jt400PgmCallException.java     |  4 ++
 .../camel/component/jt400/Jt400PgmProducer.java    | 82 ++++++++++++----------
 7 files changed, 78 insertions(+), 72 deletions(-)


[camel] 04/05: camel-google-bigquery: Close the FileInputStream in GoogleBigQueryConnectionFactory#createFromFile

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e039a8f93952fa82bb6234d67a6f4075df514b21
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Sun Dec 29 16:36:11 2019 +0100

    camel-google-bigquery: Close the FileInputStream in GoogleBigQueryConnectionFactory#createFromFile
---
 .../google/bigquery/GoogleBigQueryConnectionFactory.java      | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
index 3c7db1d..5fc3536 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
@@ -113,14 +113,15 @@ public class GoogleBigQueryConnectionFactory {
     }
 
     private GoogleCredential createFromFile() throws Exception {
+        try (InputStream is = new FileInputStream(credentialsFileLocation)) {
+            GoogleCredential credential = GoogleCredential.fromStream(is);
 
-        GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(credentialsFileLocation));
+            if (credential.createScopedRequired()) {
+                credential = credential.createScoped(BigqueryScopes.all());
+            }
 
-        if (credential.createScopedRequired()) {
-            credential = credential.createScoped(BigqueryScopes.all());
+            return credential;
         }
-
-        return credential;
     }
 
     private GoogleCredential createDefault() throws Exception {


[camel] 02/05: CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the 2nd patch.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 868eb80aa2071634c6bbdf894a8d07b20b046e22
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 30 10:07:37 2019 +0100

    CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the 2nd patch.
---
 .../component/jt400/Jt400DataQueueProducer.java    | 26 +++++++---------------
 .../component/jt400/Jt400DataQueueService.java     | 10 +++++++--
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
index 8f3c282..65c38ba 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
@@ -33,12 +33,9 @@ public class Jt400DataQueueProducer extends DefaultProducer {
     /**
      * Performs the lifecycle logic of this producer.
      */
-    private final Jt400DataQueueService queueService;
-
     protected Jt400DataQueueProducer(Jt400Endpoint endpoint) {
         super(endpoint);
         this.endpoint = endpoint;
-        this.queueService = new Jt400DataQueueService(endpoint);
     }
 
     /**
@@ -53,11 +50,14 @@ public class Jt400DataQueueProducer extends DefaultProducer {
      */
     @Override
     public void process(Exchange exchange) throws Exception {
-        BaseDataQueue queue = queueService.getDataQueue();
-        if (endpoint.isKeyed()) {
-            process((KeyedDataQueue) queue, exchange);
-        } else {
-            process((DataQueue) queue, exchange);
+        try (Jt400DataQueueService queueService = new Jt400DataQueueService(endpoint)) {
+            queueService.start();
+            BaseDataQueue queue = queueService.getDataQueue();
+            if (endpoint.isKeyed()) {
+                process((KeyedDataQueue) queue, exchange);
+            } else {
+                process((DataQueue) queue, exchange);
+            }
         }
     }
 
@@ -77,14 +77,4 @@ public class Jt400DataQueueProducer extends DefaultProducer {
         }
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        queueService.start();
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        queueService.stop();
-    }
-
 }
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
index 40aaecd..276494a 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.jt400;
 
+import java.io.IOException;
+
 import com.ibm.as400.access.AS400;
 import com.ibm.as400.access.BaseDataQueue;
 import com.ibm.as400.access.DataQueue;
@@ -69,7 +71,7 @@ class Jt400DataQueueService implements Service {
             }
         }
         if (!queue.getSystem().isConnected(AS400.DATAQUEUE)) {
-            LOG.info("Connecting to {}", endpoint);
+            LOG.debug("Connecting to {}", endpoint);
             try {
                 queue.getSystem().connectService(AS400.DATAQUEUE);
             } catch (Exception e) {
@@ -81,7 +83,7 @@ class Jt400DataQueueService implements Service {
     @Override
     public void stop() {
         if (queue != null) {
-            LOG.info("Releasing connection to {}", endpoint);
+            LOG.debug("Releasing connection to {}", endpoint);
             AS400 system = queue.getSystem();
             queue = null;
             endpoint.releaseSystem(system);
@@ -99,4 +101,8 @@ class Jt400DataQueueService implements Service {
         return queue;
     }
 
+    @Override
+    public void close() throws IOException {
+        stop();
+    }
 }


[camel] 05/05: Fix build broken by d0d2df571400e87f130866c3eced085504b7e125

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 113e81452f1e1a116bca020f1bb1273bb14e64da
Author: Jan Bednář <ma...@janbednar.eu>
AuthorDate: Sun Dec 29 23:09:59 2019 +0100

    Fix build broken by d0d2df571400e87f130866c3eced085504b7e125
---
 .../camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
index 5fc3536..f0a8879 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConnectionFactory.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.google.bigquery;
 
 import java.io.FileInputStream;
+import java.io.InputStream;
 import java.security.KeyFactory;
 import java.security.PrivateKey;
 import java.security.spec.PKCS8EncodedKeySpec;


[camel] 03/05: camel-aws-lambda: Close FileInputStreams in LambdaProducer#createFunction because com.amazonaws.util.IOUtils#toByteArray requires the client to close the InputStream.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c95d049f74ed691f97585fb6a838af625ecfec40
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Sun Dec 29 16:35:18 2019 +0100

    camel-aws-lambda: Close FileInputStreams in LambdaProducer#createFunction because com.amazonaws.util.IOUtils#toByteArray requires the client to close the InputStream.
---
 .../org/apache/camel/component/aws/lambda/LambdaProducer.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
index 3058764..2380441 100644
--- a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
+++ b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
@@ -202,8 +202,9 @@ public class LambdaProducer extends DefaultProducer {
             if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(LambdaConstants.ZIP_FILE))) {
                 String zipFile = exchange.getIn().getHeader(LambdaConstants.ZIP_FILE, String.class);
                 File fileLocalPath = new File(zipFile);
-                FileInputStream inputStream = new FileInputStream(fileLocalPath);
-                functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                try (FileInputStream inputStream = new FileInputStream(fileLocalPath)) {
+                    functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                }
             }
             if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
                 functionCode.withZipFile(exchange.getIn().getBody(ByteBuffer.class));
@@ -337,8 +338,9 @@ public class LambdaProducer extends DefaultProducer {
             if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(LambdaConstants.ZIP_FILE))) {
                 String zipFile = exchange.getIn().getHeader(LambdaConstants.ZIP_FILE, String.class);
                 File fileLocalPath = new File(zipFile);
-                FileInputStream inputStream = new FileInputStream(fileLocalPath);
-                functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                try (FileInputStream inputStream = new FileInputStream(fileLocalPath)) {
+                    functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                }
             }
             if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
                 functionCode.withZipFile(exchange.getIn().getBody(ByteBuffer.class));


[camel] 01/05: CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the patch.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6292b09c640da019cd20a509aa3e185a077b43a1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Dec 27 14:37:40 2019 +0100

    CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the patch.
---
 .../camel/component/jt400/Jt400Endpoint.java       |  6 --
 .../component/jt400/Jt400PgmCallException.java     |  4 ++
 .../camel/component/jt400/Jt400PgmProducer.java    | 82 ++++++++++++----------
 3 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
index 4b5d99a..7fb2c0e 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
@@ -94,12 +94,6 @@ public class Jt400Endpoint extends ScheduledPollEndpoint implements MultipleCons
         }
     }
 
-    @Override
-    public boolean isSingleton() {
-        // cannot be singleton as we store an AS400 instance on the configuration
-        return false;
-    }
-
     /**
      * Obtains an {@code AS400} object that connects to this endpoint. Since
      * these objects represent limited resources, clients have the
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmCallException.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmCallException.java
index d42561d..1ad1bae 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmCallException.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmCallException.java
@@ -25,4 +25,8 @@ public class Jt400PgmCallException extends RuntimeCamelException {
     public Jt400PgmCallException(String message) {
         super(message);
     }
+
+    public Jt400PgmCallException(Exception e) {
+        super(e);
+    }
 }
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmProducer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmProducer.java
index 9a17fdb..42508cb 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmProducer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400PgmProducer.java
@@ -37,8 +37,6 @@ import org.slf4j.LoggerFactory;
 public class Jt400PgmProducer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(Jt400PgmProducer.class);
-    
-    private AS400 iSeries;
 
     public Jt400PgmProducer(Jt400Endpoint endpoint) {
         super(endpoint);
@@ -51,39 +49,52 @@ public class Jt400PgmProducer extends DefaultProducer {
     @Override
     public void process(Exchange exchange) throws Exception {
 
-        String commandStr = getISeriesEndpoint().getObjectPath();
-        ProgramParameter[] parameterList = getParameterList(exchange);
+        AS400 iSeries = null;
+        try {
+            iSeries = connect();
 
-        ProgramCall pgmCall;
-        if (getISeriesEndpoint().getType() == Jt400Type.PGM) {
-            pgmCall = new ProgramCall(iSeries);
-        } else {
-            pgmCall = new ServiceProgramCall(iSeries);
-            ((ServiceProgramCall)pgmCall).setProcedureName(getISeriesEndpoint().getProcedureName());
-            ((ServiceProgramCall)pgmCall).setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);
-        }
-        pgmCall.setProgram(commandStr);
-        pgmCall.setParameterList(parameterList);
+            String commandStr = getISeriesEndpoint().getObjectPath();
+            ProgramParameter[] parameterList = getParameterList(exchange, iSeries);
+
+            ProgramCall pgmCall;
+            if (getISeriesEndpoint().getType() == Jt400Type.PGM) {
+                pgmCall = new ProgramCall(iSeries);
+            } else {
+                pgmCall = new ServiceProgramCall(iSeries);
+                ((ServiceProgramCall) pgmCall)
+                    .setProcedureName(getISeriesEndpoint().getProcedureName());
+                ((ServiceProgramCall) pgmCall)
+                    .setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);
+            }
+            pgmCall.setProgram(commandStr);
+            pgmCall.setParameterList(parameterList);
 
-        if (LOG.isDebugEnabled()) {
-            LOG.trace("Starting to call PGM '{}' in host '{}' authentication with the user '{}'",
+            if (LOG.isDebugEnabled()) {
+                LOG.trace(
+                    "Starting to call PGM '{}' in host '{}' authentication with the user '{}'",
                     new Object[]{commandStr, iSeries.getSystemName(), iSeries.getUserId()});
-        }
+            }
 
-        boolean result = pgmCall.run();
+            boolean result = pgmCall.run();
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("Executed PGM '{}' in host '{}'. Success? {}", commandStr, iSeries.getSystemName(), result);
-        }
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Executed PGM '{}' in host '{}'. Success? {}", commandStr,
+                    iSeries.getSystemName(), result);
+            }
 
-        if (result) {
-            handlePGMOutput(exchange, pgmCall, parameterList);
-        } else {
-            throw new Jt400PgmCallException(getOutputMessages(pgmCall));
+            if (result) {
+                handlePGMOutput(exchange, pgmCall, parameterList, iSeries);
+            } else {
+                throw new Jt400PgmCallException(getOutputMessages(pgmCall));
+            }
+        } catch (Exception e) {
+            throw new Jt400PgmCallException(e);
+        } finally {
+            release(iSeries);
         }
     }
 
-    private ProgramParameter[] getParameterList(Exchange exchange) throws InvalidPayloadException, PropertyVetoException {
+    private ProgramParameter[] getParameterList(Exchange exchange, AS400 iSeries) throws InvalidPayloadException, PropertyVetoException {
 
         Object body = exchange.getIn().getMandatoryBody();
 
@@ -147,7 +158,7 @@ public class Jt400PgmProducer extends DefaultProducer {
         return parameterList;
     }
 
-    private void handlePGMOutput(Exchange exchange, ProgramCall pgmCall, ProgramParameter[] inputs) throws InvalidPayloadException {
+    private void handlePGMOutput(Exchange exchange, ProgramCall pgmCall, ProgramParameter[] inputs, AS400 iSeries) throws InvalidPayloadException {
 
         Object body = exchange.getIn().getMandatoryBody();
         Object[] params = (Object[]) body;
@@ -196,23 +207,20 @@ public class Jt400PgmProducer extends DefaultProducer {
         return outputMsg.toString();
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        if (iSeries == null) {
-            iSeries = getISeriesEndpoint().getSystem();
-        }
+    private AS400 connect() throws Exception {
+        AS400 iSeries = getISeriesEndpoint().getSystem();
         if (!iSeries.isConnected(AS400.COMMAND)) {
-            LOG.info("Connecting to {}", getISeriesEndpoint());
+            LOG.debug("Connecting to {}", getISeriesEndpoint());
             iSeries.connectService(AS400.COMMAND);
         }
+
+        return iSeries;
     }
 
-    @Override
-    protected void doStop() throws Exception {
+    private void release(AS400 iSeries) throws Exception {
         if (iSeries != null) {
-            LOG.info("Releasing connection to {}", getISeriesEndpoint());
+            LOG.debug("Releasing connection to {}", getISeriesEndpoint());
             getISeriesEndpoint().releaseSystem(iSeries);
-            iSeries = null;
         }
     }