shashank created CAMEL-25319:
--------------------------------
Summary: camel-aws2-sqs - batchSeparator is used as a regular
expression: with | every character is sent as a message, with . nothing is sent
Key: CAMEL-25319
URL: https://issues.apache.org/jira/browse/CAMEL-25319
Project: Camel
Issue Type: Bug
Components: camel-aws2-sqs
Reporter: shashank
The {{sendBatchMessage}} operation splits a {{String}} body into the messages
of the batch with
{code:java}
String[] elements = c.split(getConfiguration().getBatchSeparator());
{code}
{{String.split}} takes a regular expression, but the option is documented as
"the separator when passing a String to send batch message operation" (default
{{,}}). With {{batchSeparator=|}} the body {{team1|team2|team3}} is sent as 17
messages ({{t}}, {{e}}, {{a}}, ..., including the {{|}} characters), in two
batch requests; with {{batchSeparator=.}} no message is sent. Other
metacharacters ({{+}}, {{*}}, {{?}}, {{(}}, {{[}}, {{$}}, {{^}}, a backslash)
fail or split wrongly.
h3. Reproduction
New {{SqsProducerBatchSeparatorTest}} (the module's {{AmazonSQSClientMock}}):
{{|}} gives {{[t, e, a, m, 1, |, t, e, a, m, 2, |, t, e, a, m, 3]}} instead of
{{[team1, team2, team3]}}, {{.}} gives {{[]}}; the default {{,}} is the
control. Two runs on main.
h3. Proposed fix
{{Pattern.quote}} the separator. Separators that are not regex metacharacters
(the default {{,}}, {{;}}, a line break) split exactly as before; a route that
escaped the separator to work around this (for example {{batchSeparator=\\|}})
must use the separator itself. The same holds for escape sequences that the
regex interpreted: {{batchSeparator=\\n}} written in an endpoint URI split at
line breaks on main (checked) and is now the two characters backslash and
{{n}}; {{batchSeparator=%0A}} works before and after. Upgrade guide entry for
both. Neither the option documentation, the component page nor the
{{aws-sqs-batch-sink}} Kamelet ("The batch separator string") mention a regular
expression, so the code is fixed rather than the documentation. Module: 75
tests pass.
Found with a Lean 4 model of the split: "the messages are the pieces between
the separators" fails on main for {{|}} (n one-character messages for every
body of n characters) and {{.}} (no message for every body), and the fix is
proved equal to main for every separator character the model treats as plain
(it models only {{|}} and {{.}} as special, so the other metacharacters listed
above are not covered by the proof).
Affected: 4.14.x, 4.18.x and main.
Duplicate check (2026-10-04): JIRA "batchSeparator": only CAMEL-24086 (FIFO
deduplication id); GitHub pull requests "batchSeparator": only #24728
(CAMEL-24086).
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)