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 2022/08/17 07:34:41 UTC

[camel] branch camel-3.14.x updated: CAMEL-18399: Fix PreparedStatement NullPointerException (#8170)

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

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


The following commit(s) were added to refs/heads/camel-3.14.x by this push:
     new 3ced7367d4e CAMEL-18399: Fix PreparedStatement NullPointerException (#8170)
3ced7367d4e is described below

commit 3ced7367d4e948778e48678f2edce8490ad38ff0
Author: Alexandre Davi Zanelatto <al...@gmail.com>
AuthorDate: Wed Aug 17 04:33:41 2022 -0300

    CAMEL-18399: Fix PreparedStatement NullPointerException (#8170)
    
    Co-authored-by: Alexandre Zanelatto <al...@apipass.com.br>
---
 .../src/main/java/org/apache/camel/component/sql/SqlProducer.java      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index c34bac9cd46..bf8e9bcfcbb 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -250,7 +250,8 @@ public class SqlProducer extends DefaultProducer {
 
     private void populateStatement(PreparedStatement ps, Exchange exchange, String sql, String preparedQuery)
             throws SQLException {
-        int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount();
+        int psParametersCount = ps.getParameterMetaData() != null ? ps.getParameterMetaData().getParameterCount() : 0;
+        int expected = parametersCount > 0 ? parametersCount : psParametersCount;
 
         // only populate if really needed
         if (alwaysPopulateStatement || expected > 0) {