This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new ff9971a4e216 CAMEL-24047: camel-sql - verifyTableName accepts
schema-qualified names
ff9971a4e216 is described below
commit ff9971a4e2168900ff24d9db92cf0b8d8a262e9a
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jul 15 13:00:38 2026 +0200
CAMEL-24047: camel-sql - verifyTableName accepts schema-qualified names
Updated the table-name validation regex in JdbcAggregationRepository to
accept
schema-qualified names (e.g. myschema.camel_agg). The previous regex only
allowed
simple identifiers, rejecting any name containing a dot. This was an
unreleased
regression from commit 1d2568f00236.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../aggregate/jdbc/JdbcAggregationRepository.java | 3 +-
...bcAggregationRepositoryVerifyTableNameTest.java | 92 ++++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_22.adoc | 7 ++
3 files changed, 101 insertions(+), 1 deletion(-)
diff --git
a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepository.java
b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepository.java
index 800ab575fba2..0593b7f71227 100644
---
a/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepository.java
+++
b/components/camel-sql/src/main/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepository.java
@@ -240,8 +240,9 @@ public class JdbcAggregationRepository extends
ServiceSupport
}
// Useful to verify if the table name does not contain invalid characters.
+ // Allows simple names (my_table) and schema-qualified names
(myschema.my_table).
protected static void verifyTableName(String tableName) {
- if (!tableName.matches("[a-zA-Z_][a-zA-Z0-9_]*")) {
+ if
(!tableName.matches("[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)?")) {
throw new IllegalArgumentException("Invalid repository name: " +
tableName);
}
}
diff --git
a/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryVerifyTableNameTest.java
b/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryVerifyTableNameTest.java
new file mode 100644
index 000000000000..dece7bf0da90
--- /dev/null
+++
b/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryVerifyTableNameTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.aggregate.jdbc;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class JdbcAggregationRepositoryVerifyTableNameTest {
+
+ @Test
+ public void testSimpleNameAccepted() {
+ assertDoesNotThrow(() ->
JdbcAggregationRepository.verifyTableName("aggregation"));
+ }
+
+ @Test
+ public void testSimpleNameWithUnderscoreAccepted() {
+ assertDoesNotThrow(() ->
JdbcAggregationRepository.verifyTableName("camel_agg"));
+ }
+
+ @Test
+ public void testNameStartingWithUnderscoreAccepted() {
+ assertDoesNotThrow(() ->
JdbcAggregationRepository.verifyTableName("_my_table"));
+ }
+
+ @Test
+ public void testSchemaQualifiedNameAccepted() {
+ assertDoesNotThrow(() ->
JdbcAggregationRepository.verifyTableName("myschema.camel_agg"));
+ }
+
+ @Test
+ public void testSchemaQualifiedCompletedNameAccepted() {
+ assertDoesNotThrow(() ->
JdbcAggregationRepository.verifyTableName("myschema.camel_agg_completed"));
+ }
+
+ @Test
+ public void testSqlInjectionRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () -> JdbcAggregationRepository.verifyTableName("foo; DROP
TABLE bar"));
+ }
+
+ @Test
+ public void testEmptyNameRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () -> JdbcAggregationRepository.verifyTableName(""));
+ }
+
+ @Test
+ public void testNameStartingWithDigitRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () -> JdbcAggregationRepository.verifyTableName("1table"));
+ }
+
+ @Test
+ public void testDoubleDotRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () ->
JdbcAggregationRepository.verifyTableName("schema..table"));
+ }
+
+ @Test
+ public void testTrailingDotRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () -> JdbcAggregationRepository.verifyTableName("schema."));
+ }
+
+ @Test
+ public void testLeadingDotRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () -> JdbcAggregationRepository.verifyTableName(".table"));
+ }
+
+ @Test
+ public void testMultipleDotsRejected() {
+ assertThrows(IllegalArgumentException.class,
+ () ->
JdbcAggregationRepository.verifyTableName("catalog.schema.table"));
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
index 80325fece7c1..61e5b7cd109c 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc
@@ -448,3 +448,10 @@ The aggregation tables used with these repositories must
have the `version BIGIN
already required by `JdbcAggregationRepository` for reading and updating
aggregates. When
`recoveryByInstance` is enabled, the completed table must have the
`instance_id VARCHAR(255)`
column as documented.
+
+=== camel-sql - Schema-qualified aggregation repository names
+
+The table-name validation in `JdbcAggregationRepository` now accepts
schema-qualified names
+such as `myschema.aggregation`. Previously the validation regex only allowed
simple identifiers
+(`[a-zA-Z_][a-zA-Z0-9_]*`), rejecting any name containing a dot. Names
starting with a digit,
+containing spaces, or with multiple dots (e.g. `catalog.schema.table`) are
still rejected.