[
https://issues.apache.org/jira/browse/CAMEL-26091?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26091 started by Claus Ibsen.
-------------------------------------------
> camel-aws2-redshift - aws2-redshift-data fails with a NullPointerException
> unless a RedshiftDataClient is given
> ---------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26091
> URL: https://issues.apache.org/jira/browse/CAMEL-26091
> Project: Camel
> Issue Type: Bug
> Components: camel-aws2
> Affects Versions: 4.18.0, 4.22.0, 4.23.0
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of aws2-redshift-data (CAMEL-24961).
> h4. 1. Every operation fails with a NullPointerException unless a
> RedshiftDataClient is given
> The endpoint builds its client in {{doStart}} from the accessKey and
> secretKey, the default credentials provider or a profile
> ({{RedshiftData2Endpoint}}, main ed3d719b379c, lines 71-73), and keeps it in
> a field. The producer never uses it: every operation is called with
> {{getConfiguration().getAwsRedshiftDataClient()}} ({{RedshiftData2Producer}},
> lines 51-61), which is null unless the awsRedshiftDataClient option is set or
> a RedshiftDataClient bean is autowired. So with the keys only, as the page
> says works (lines 49-50), every exchange fails with {{NullPointerException:
> Cannot invoke "...RedshiftDataClient.listDatabases(...)" because
> "redshiftDataClient" is null}}. Checked on 4.24.0-SNAPSHOT with {{camel run}}
> against the AWS emulator of {{camel infra run aws}}. It has been so since the
> component was added (4.1.0); the tests always bind a client.
> *Proposed change*: call the operations with
> {{getEndpoint().getAwsRedshiftDataClient()}}.
> h4. 2. No operation fails with a NullPointerException
> The operation option has no default, and with no
> CamelAwsRedshiftDataOperation header, {{switch
> (determineOperation(exchange))}} ({{RedshiftData2Producer}}, main
> ed3d719b379c, line 51) fails with {{NullPointerException: Cannot invoke
> "...ordinal()" because the return value of "...determineOperation(...)" is
> null}}. Checked on 4.24.0-SNAPSHOT with {{camel run}} against a fake of the
> AWS API that logs the requests it gets.
> *Proposed change*: fail with a message that says to set the operation option
> or header, as aws2-kms does ("Operation must be specified").
> h4. 3. A CamelAwsRedshiftDataSqlParameterList of Strings fails with a
> ClassCastException
> The header is passed to {{builder.parameters(...)}} as a raw List (lines
> 455-458), so anything but SqlParameter objects of the AWS SDK fails in the
> SDK with {{ClassCastException: class java.lang.String cannot be cast to class
> ...SqlParameter}}. Checked on 4.24.0-SNAPSHOT with {{camel run}} against a
> fake of the AWS API that logs the requests it gets. The catalog gives its
> type as {{List<SqlParameterList>}} ({{RedshiftData2Constants}}, line 95), a
> class that does not exist.
> h4. Also read in the code, not run
> * executeStatement does not set the {{CamelAwsRedshiftDataStatementId}}
> header from the id of the response, which describeStatement and
> getStatementResult read; getStatementResult and the list operations give one
> page, with no header for the next token.
> * The POJO example of the page uses {{ListDatabases.builder()}} (line 141);
> the class is {{ListDatabasesRequest}}.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)