Andrea Cosentino created CAMEL-24348:
----------------------------------------

             Summary: camel-google-bigquery: NPEs on a null body or unknown job 
id, and insertId is ignored for List bodies
                 Key: CAMEL-24348
                 URL: https://issues.apache.org/jira/browse/CAMEL-24348
             Project: Camel
          Issue Type: Bug
          Components: camel-google-bigquery
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino


1. A null message body gives an NPE while building the error message:
{code:java}
// GoogleBigQueryProducer.java:137-139
} else {
    ex.setException(new IllegalArgumentException("Cannot handle body type " + 
entryObject.getClass()));
}
{code}

2. The List branch never reads the insert-id header:
{code:java}
// GoogleBigQueryProducer.java:131-136
if (entryObject instanceof List) {
    for (Map<String, Object> entry : (List<Map<String, Object>>) entryObject) {
        apiRequestRows.add(createRowRequest(null, entry));
    }
} else if (entryObject instanceof Map) {
    apiRequestRows.add(createRowRequest(ex, (Map<String, Object>) entryObject));
}
{code}
{{createRowRequest}} only consults {{CamelGoogleBigQueryInsertId}} when an 
exchange is passed (:183-185), so the header is silently ignored for List 
payloads.

3. In the SQL producer, a user-supplied {{CamelGoogleBigQueryJobId}} that no 
longer resolves gives an NPE:
{code:java}
// GoogleBigQuerySQLProducer.java:157-161
var job = ObjectHelper.isNotEmpty(jobId) ? bigquery.getJob(jobId) : 
bigquery.create(getJobInfo(queryJobConfiguration));
return job.waitFor();
{code}
Both {{getJob}} and {{waitFor}} return null for a job that does not exist any 
more.

4. Three raw {{throw new Exception(...)}} (GoogleBigQueryProducer:163, 
GoogleBigQuerySQLProducer:163 and :189) should be typed Camel exceptions.

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)

Reply via email to