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:18 UTC

[camel] branch camel-3.18.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.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


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

commit 2b0ceb402d185d8d82ef777e97e74ebde4da697a
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 ca2840bc23a..c0c606416e8 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
@@ -245,7 +245,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) {