Claus Ibsen created CAMEL-27686:
-----------------------------------

             Summary: camel-kudu: endpoint URI lacks scheme, NPE without 
operation, scan limit cast, tableName
                 Key: CAMEL-27686
                 URL: https://issues.apache.org/jira/browse/CAMEL-27686
             Project: Camel
          Issue Type: Bug
          Components: camel-kudu
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-kudu for CAMEL-23832 
(commit 
https://github.com/apache/camel/commit/5dffc8242e39c1ce5227937fdd86bbda27b16bf2).
These are separate problems of the component; the descriptions commit only 
documents the current behavior.

h4. 1. The endpoint URI has no scheme and no query
{{KuduComponent.createEndpoint()}} passes {{remaining}} instead of {{uri}} to 
the {{KuduEndpoint}} constructor, which hands it to {{DefaultEndpoint}} as the 
endpoint URI. So {{getEndpointUri()}} of 
{{kudu:localhost:7051/TestTable?operation=insert}} returns 
{{localhost:7051/TestTable}}. The insert and the scan endpoint of one table 
show the same string in JMX, in the route dump and in log messages.
Pass {{uri}} to the constructor and parse {{remaining}} separately for host, 
port and table name.

h4. 2. A missing operation fails every exchange with a NullPointerException
The {{operation}} option is not required and has no default. 
{{KuduProducer.process()}} does {{switch (endpoint.getOperation())}}, which 
throws a {{NullPointerException}} for each exchange when the option is not set. 
The route starts without any hint.
Mark {{operation}} as required, or check it in {{KuduProducer.doStart()}} with 
a clear message.

h4. 3. The scan limit header is cast, not converted
{{KuduProducer.doScan()}} reads {{CamelKuduScanLimit}} with {{(Long) 
exchange.getIn().getHeader(...)}}. An {{Integer}} value (for example 
{{setHeader("CamelKuduScanLimit", constant(10))}}) or a {{String}} value fails 
with a {{ClassCastException}}.
Use {{getHeader(KuduConstants.CAMEL_KUDU_SCAN_LIMIT, Long.class)}} so the type 
converter handles it.

h4. 4. tableName is not marked as required
The {{tableName}} path option is {{required: false}} in the metadata. The regex 
{{^(\S+)\:(\d+)\/(\S+)$}} in the {{KuduEndpoint}} constructor requires a table 
name, and a URI without one fails with "Unrecognizable url".
Add {{@Metadata(required = true)}} to {{tableName}}.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to