Claus Ibsen created CAMEL-25074:
-----------------------------------
Summary: camel-sql - say in the outputType description that a
StreamList body is an Iterator with no size
Key: CAMEL-25074
URL: https://issues.apache.org/jira/browse/CAMEL-25074
Project: Camel
Issue Type: Improvement
Components: camel-sql
Reporter: Claus Ibsen
{{outputType=StreamList}} makes the body a {{ResultSetIterator}}. The option's
description says the result is streamed "using an Iterator" and that it "can be
used with the Splitter EIP in streaming mode", which is accurate but leaves out
what it costs: the body has no size, and it can be read only once.
Anyone who then treats the body as a list gets an error that does not mention
the option they chose:
{noformat}
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
size() not found on bean:
org.apache.camel.component.sql.ResultSetIterator@1bdc4d7c
{noformat}
Measured while benchmarking how well a local model writes Camel routes. A step
that selects the rows of a table, logs {{${body.size()}}} and splits the list
was written 30 times across three 10-pass runs. The model chose {{outputType}}
freely, and:
* {{SelectList}} or no {{outputType}} -- worked;
* {{StreamList}} -- failed *8 times out of 8*, always on {{${body.size()}}}.
It reads "streams the result using an Iterator ... can be used with the
Splitter", picks it, and then sizes the body anyway. The description is not
wrong; it just stops one sentence short of the consequence.
Adding that sentence to the option's description, so it reaches the catalog,
the component page and every tool that reads them:
{noformat}
The body is then a ResultSetIterator and not a List: it has no size, and it can
only be read once, so split it
to work on the rows instead of calling size() or indexing it. Use SelectList
when the whole result is wanted as
a List of Map.
{noformat}
Same shape as CAMEL-25040: the catalog names an option but not what follows
from choosing it, and that is the part an author needs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)