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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 82e343f4fda32a5746dfbc422c3c1d8e67f6780b
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Jan 26 10:42:19 2026 +0000

    (chores): modernize instanceof checks in camel-jdbc
---
 .../org/apache/camel/component/jdbc/JdbcProducer.java    | 16 ++++++++--------
 .../apache/camel/component/jdbc/ResultSetIterator.java   |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

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 d2cf535c525b..f56bb7588cfe 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
@@ -173,10 +173,10 @@ public class JdbcProducer extends DefaultProducer {
                 Object expectedGeneratedColumns = 
exchange.getIn().getHeader(JdbcConstants.JDBC_GENERATED_COLUMNS);
                 if (expectedGeneratedColumns == null) {
                     ps = conn.prepareStatement(preparedQuery, 
Statement.RETURN_GENERATED_KEYS);
-                } else if (expectedGeneratedColumns instanceof String[]) {
-                    ps = conn.prepareStatement(preparedQuery, (String[]) 
expectedGeneratedColumns);
-                } else if (expectedGeneratedColumns instanceof int[]) {
-                    ps = conn.prepareStatement(preparedQuery, (int[]) 
expectedGeneratedColumns);
+                } else if (expectedGeneratedColumns instanceof String[] 
stringArray) {
+                    ps = conn.prepareStatement(preparedQuery, stringArray);
+                } else if (expectedGeneratedColumns instanceof int[] intArray) 
{
+                    ps = conn.prepareStatement(preparedQuery, intArray);
                 } else {
                     throw new IllegalArgumentException(
                             "Header specifying expected returning columns 
isn't an instance of String[] or int[] but "
@@ -256,10 +256,10 @@ public class JdbcProducer extends DefaultProducer {
                 Object expectedGeneratedColumns = 
exchange.getIn().getHeader(JdbcConstants.JDBC_GENERATED_COLUMNS);
                 if (expectedGeneratedColumns == null) {
                     stmtExecutionResult = stmt.execute(sql, 
Statement.RETURN_GENERATED_KEYS);
-                } else if (expectedGeneratedColumns instanceof String[]) {
-                    stmtExecutionResult = stmt.execute(sql, (String[]) 
expectedGeneratedColumns);
-                } else if (expectedGeneratedColumns instanceof int[]) {
-                    stmtExecutionResult = stmt.execute(sql, (int[]) 
expectedGeneratedColumns);
+                } else if (expectedGeneratedColumns instanceof String[] 
stringArray) {
+                    stmtExecutionResult = stmt.execute(sql, stringArray);
+                } else if (expectedGeneratedColumns instanceof int[] intArray) 
{
+                    stmtExecutionResult = stmt.execute(sql, intArray);
                 } else {
                     throw new IllegalArgumentException(
                             "Header specifying expected returning columns 
isn't an instance of String[] or int[] but "
diff --git 
a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
 
b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
index a44abb7a3475..99c1dab505a3 100644
--- 
a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
+++ 
b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/ResultSetIterator.java
@@ -83,8 +83,8 @@ public class ResultSetIterator implements 
Iterator<Map<String, Object>> {
         try {
             Map<String, Object> row = new LinkedHashMap<>();
             for (Column column : columns) {
-                if (useGetBytes && column instanceof BlobColumn) {
-                    row.put(column.getName(), ((BlobColumn) 
column).getBytes(resultSet));
+                if (useGetBytes && column instanceof BlobColumn blobcolumn) {
+                    row.put(column.getName(), blobcolumn.getBytes(resultSet));
                 } else {
                     row.put(column.getName(), column.getValue(resultSet));
                 }

Reply via email to