Andrea Cosentino created CAMEL-24346:
----------------------------------------
Summary: camel-google-sheets: splitResults always reports range
index 1 and NPEs on an empty range
Key: CAMEL-24346
URL: https://issues.apache.org/jira/browse/CAMEL-24346
Project: Camel
Issue Type: Bug
Components: camel-google-sheets
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
In {{GoogleSheetsStreamConsumer.poll()}} the range counter is allocated inside
the per-range loop:
{code:java}
// GoogleSheetsStreamConsumer.java:88-104
for (ValueRange valueRange : response.getValueRanges()) {
AtomicInteger rangeIndex = new AtomicInteger(1);
...
rangeIndex.incrementAndGet();
}
{code}
so with {{splitResults=true}} and several comma-separated ranges every exchange
carries {{CamelGoogleSheetsRangeIndex=1}} and the trailing increment is dead.
The non-split branch (:107) uses a single counter and is correct.
Two more items in the same method:
* {{valueRange.getValues()}} is dereferenced without a null check (:92, :111) -
an empty range has no {{values}} field and gives an NPE.
* The non-range branch (:121-128) never calls {{forceConsumerAsReady()}}, so
the consumer readiness check is only satisfied when a range is configured.
Found during a source audit of the {{components/camel-google}} module family
against main @ c3b01310be15.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)