Claus Ibsen created CAMEL-24969:
-----------------------------------
Summary: simple - collection and misc function fixes
Key: CAMEL-24969
URL: https://issues.apache.org/jira/browse/CAMEL-24969
Project: Camel
Issue Type: Sub-task
Components: camel-core
Reporter: Claus Ibsen
Assignee: Claus Ibsen
Fix For: 4.23.0
Bugs in CollectionExpressionBuilder, MiscExpressionBuilder and
CollectionFunctionFactory.
* (verified) {{${split(${body},'.')}}} returns [] and {{'|'}} splits every
character: the separator is used as a regex. Use Pattern.quote (keep \n
working).
* (verified) {{${sort(${header.list})}}} sorts the body; a single argument is
always parsed as the reverse flag.
* (verified) A space after a comma leaks into the argument: {{${sort(${body},
true)}}} is not reversed; {{${mapAdd(${body}, 'k', 'v')}}} stores " k"/" v".
Affects sort, split, listAdd, listRemove, mapAdd, mapRemove, forEach, filter.
* (verified) {{${range(5)}}} returns [1,2,3,4]; the docs say 0..4 (random(max)
starts at 0). CollectionFunctionFactoryTest pins the current result, so this
needs a decision.
* (verified) {{${uuid()}}} fails with "No bean could be found in the registry
for: of type UuidGenerator" (empty generator name). Also only "classic" is
case-insensitive.
* (verified) {{${collate(${header.n})}}} with a missing header gives NPE;
{{${range(1,${header.n})}}} too; {{${random(5,5)}}} gives "bound must be
positive"; {{${range(-2,2)}}} silently returns null.
* (verified) Body exactly "," crashes isEmpty/distinct/sort/reverse/forEach
with StringIndexOutOfBoundsException (camel-util splitOnCharacterAsIterator).
* kindOfType misclassifies BigDecimal (object), Map/JsonObject (array) and
String[] (object); duplicated in safeQuote.
* hash never closes the InputStream (File/GenericFile body leaks a
FileInputStream).
* mapAdd/mapRemove key is never evaluated ({{${mapAdd(${header.k},'v')}}}
stores the literal text). isEmpty is true for [null]. forEach silently drops
null results. listRemove(20) on List<Integer> treats 20 as an index.
_Claude Code on behalf of davsclaus (found by an AI review of the simple
language source; each item marked (verified) was reproduced on main at
c3ef718de2e8)_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)