[ 
https://issues.apache.org/jira/browse/CAMEL-24348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18103792#comment-18103792
 ] 

Andrea Cosentino commented on CAMEL-24348:
------------------------------------------

https://github.com/apache/camel/pull/25448 fixes the null-body NPE, the 
unguarded job lookups and the raw java.lang.Exception throws.

Item 2 of the description (the insert id header being ignored for List bodies) 
is WITHDRAWN: it is correct as it stands. BigQuery uses the insert id for 
best-effort deduplication, so applying one header value to every row of a list 
would make it keep a single row and drop the others. useAsInsertId, which names 
a field of each row, is the right option for list payloads. The PR only adds a 
code comment recording this.

> 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
>            Priority: Minor
>
> 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