Claus Ibsen created CAMEL-24968:
-----------------------------------

             Summary: simple - string, math, date and file function fixes
                 Key: CAMEL-24968
                 URL: https://issues.apache.org/jira/browse/CAMEL-24968
             Project: Camel
          Issue Type: Sub-task
          Components: camel-core
            Reporter: Claus Ibsen
            Assignee: Claus Ibsen
             Fix For: 4.23.0


Bugs in StringExpressionBuilder, MathExpressionBuilder, DateExpressionBuilder, 
FileExpressionBuilder.

* (verified) {{${capitalize()}}} on an empty body throws 
ArrayIndexOutOfBoundsException (StringHelper.doCapitalize). Its word loop also 
starts at index 2.
* (verified) {{${sum()}}} / {{${max()}}} / min / average with no arguments 
return null; the docs say they work on the body.
* (verified) {{${sum(1.5,2)}}} returns 2: non-integral values are silently 
dropped (Double body values are truncated instead). average truncates, sum can 
overflow, abs(Long.MIN_VALUE) stays negative.
* (verified) {{${date:header.Last-Modified}}} fails (NumberFormatException 
"Mo"), {{${date:header.X-Date}}} reads header X: the command is split on [+-] 
as offsets. HTTP date headers are the obvious case.
* (verified) {{${date:header.my.date}}} reads header "date" (lastIndexOf('.') 
in LanguageHelper.dateFromHeader).
* (verified) {{${date-with-timezone:now:GMT+02:00:yyyy}}} returns "00:2026": 
split(":", 3) cuts inside the timezone. Unknown timezone ids silently fall back 
to GMT.
* (verified) {{${safeQuote()}}} / quote do not escape: body {{He said "hi"}} 
gives {{"He said "hi""}} (invalid JSON). StringQuoteHelper.jsonQuote exists.
* (verified) Null argument gives bare NPE: {{${substring(${header.start})}}}, 
{{${substringBefore(${header.sep})}}} (also substringAfter/Between). pad 
already has a clear message.
* (verified) {{${substring(-3,-2)}}} on ABCDEFGHIJK gives DEFGHI; the docs 
("negative values clip from the opposite end") imply otherwise. Fix code or 
docs.
* (verified) {{${pad('foo',6,'ab')}}} gives fooabab (7 chars). The docs also 
describe the pad direction backwards.
* (verified) {{${size()}}} on Integer[]/Object[] returns 1 (only primitive 
arrays and String[] handled). Same gap in length().
* (verified) Hidden files inconsistent: CamelFileName=.bashrc gives 
file:name.noext=.bashrc but file:ext=bashrc.
* length() on a non-cached InputStream body reads and closes it (payload lost); 
a StreamCache > 2GB overflows the int cast.
* trim() uses String.trim(), missing Unicode whitespace (docs say all white 
spaces).

_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)

Reply via email to