This is an automated email from the ASF dual-hosted git repository.
Croway 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 98526edc118b CAMEL-26317: camel-console - the sql-trace console shows
a + of a statement as a space
98526edc118b is described below
commit 98526edc118b58cf7e9227b4af1744d38ed2df28
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Oct 26 09:32:51 2026 +0100
CAMEL-26317: camel-console - the sql-trace console shows a + of a statement
as a space
SqlTraceDevConsole decoded the statement of a sql: endpoint with
URLDecoder, which turns a + into a space: orders = customers.orders + 1 was
shown as orders = customers.orders 1. The endpoint uri encodes a space as
%20, so a + is a + of the statement. A % that is not an escape no longer fails
the console.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
---
.../org/apache/camel/impl/console/SqlTraceDevConsole.java | 9 +++++++--
.../impl/console/SqlTraceDevConsoleQueryHeaderTest.java | 15 ++++++++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git
a/core/camel-console/src/main/java/org/apache/camel/impl/console/SqlTraceDevConsole.java
b/core/camel-console/src/main/java/org/apache/camel/impl/console/SqlTraceDevConsole.java
index 076cd3728a80..c45dbe67a765 100644
---
a/core/camel-console/src/main/java/org/apache/camel/impl/console/SqlTraceDevConsole.java
+++
b/core/camel-console/src/main/java/org/apache/camel/impl/console/SqlTraceDevConsole.java
@@ -222,8 +222,13 @@ public class SqlTraceDevConsole extends AbstractDevConsole
{
if (idx > 0) {
query = query.substring(0, idx);
}
- // URI path is URL-encoded, decode it
- query = URLDecoder.decode(query, StandardCharsets.UTF_8);
+ // the URI path is URL-encoded with %20 for a space, so a + is
a + of the statement
+ // (orders = customers.orders + 1), which form decoding would
turn into a space
+ try {
+ query = URLDecoder.decode(query.replace("+", "%2B"),
StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException e) {
+ // a % that is not an escape: the statement as written
+ }
return query;
}
} else if (endpointUri.startsWith("jdbc:")) {
diff --git
a/core/camel-console/src/test/java/org/apache/camel/impl/console/SqlTraceDevConsoleQueryHeaderTest.java
b/core/camel-console/src/test/java/org/apache/camel/impl/console/SqlTraceDevConsoleQueryHeaderTest.java
index 232eb163044d..5d467666bda6 100644
---
a/core/camel-console/src/test/java/org/apache/camel/impl/console/SqlTraceDevConsoleQueryHeaderTest.java
+++
b/core/camel-console/src/test/java/org/apache/camel/impl/console/SqlTraceDevConsoleQueryHeaderTest.java
@@ -67,18 +67,31 @@ public class SqlTraceDevConsoleQueryHeaderTest extends
ContextTestSupport {
Assertions.assertEquals(ENDPOINT_QUERY, tracedQuery(true, true));
}
+ @Test
+ public void testAPlusInTheStatementIsKept() throws Exception {
+ // the endpoint uri has %20 for a space, so a + is a + of the
statement: it was shown as a space, and an agent
+ // reading the trace "fixed" an ON CONFLICT clause that was right
+ String statement = "update customers set orders = customers.orders + 1
where id = 'C-482'";
+ Assertions.assertEquals(statement, tracedQuery(statement, false,
false));
+ }
+
private String tracedQuery(boolean allowQueryFromHeader) throws Exception {
return tracedQuery(allowQueryFromHeader, false);
}
private String tracedQuery(boolean allowQueryFromHeader, boolean
useMessageBodyForSql) throws Exception {
+ return tracedQuery(ENDPOINT_QUERY, allowQueryFromHeader,
useMessageBodyForSql);
+ }
+
+ private String tracedQuery(String endpointQuery, boolean
allowQueryFromHeader, boolean useMessageBodyForSql)
+ throws Exception {
context.addComponent("sql", new FakeSqlComponent(allowQueryFromHeader,
useMessageBodyForSql));
DevConsole con =
PluginHelper.getDevConsoleResolver(context).resolveDevConsole("sql-trace");
Assertions.assertNotNull(con);
ServiceHelper.startService(con);
- template.sendBodyAndHeader("sql:" + ENDPOINT_QUERY, "body",
"CamelSqlQuery", HEADER_QUERY);
+ template.sendBodyAndHeader("sql:" + endpointQuery, "body",
"CamelSqlQuery", HEADER_QUERY);
JsonObject out = (JsonObject) con.call(DevConsole.MediaType.JSON);
JsonArray statements = (JsonArray) out.get("statements");