Claus Ibsen created CAMEL-26173:
-----------------------------------
Summary: camel-web3j - ETH_GET_BALANCE and ETH_GET_BLOCK_BY_NUMBER
fail with NPE without atBlock (documented default latest is null)
Key: CAMEL-26173
URL: https://issues.apache.org/jira/browse/CAMEL-26173
Project: Camel
Issue Type: Bug
Components: camel-web3j
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while adding the catalog body types of web3j (CAMEL-24961, PR #28412).
h4. 1. atBlock, fromBlock and toBlock are documented with default latest but
are null
In {{Web3jConfiguration}} (main 2a465aa4814c, lines 33-40) {{fromBlock}},
{{toBlock}} and {{atBlock}} have {{defaultValue = "latest"}} but the fields are
not initialized, and {{Web3jHelper.toDefaultBlockParameter}} (line 29) returns
null for null. So {{ETH_GET_BALANCE}} ({{Web3jProducer}} line 258) and
{{ETH_GET_BLOCK_BY_NUMBER}} (line 474) without {{atBlock}} fail every call with
a NullPointerException "defaultBlockParameter is null". The consumer passes the
same null {{fromBlock}}/{{toBlock}} to the log filter and the replay
observables ({{Web3jConsumer}} lines 91-92, 137-138, 146-147; read in the
code). Checked on 4.24.0-SNAPSHOT with a JDK HTTP server as the JSON-RPC node
(the real {{HttpService}}).
Proposed: initialize the three fields to {{"latest"}} as documented.
h4. 2. ETH_GET_TRANSACTION_RECEIPT puts an Optional in the body
{{Web3jProducer.ethGetTransactionReceipt}} (main 2a465aa4814c, line 564) sets
the body to {{response.getTransactionReceipt()}}, an
{{Optional<TransactionReceipt>}}, while the {{ETH_GET_TRANSACTION_BY_*}}
operations unwrap the Optional to the {{Transaction}} or null (lines 497, 510,
524). Checked on 4.24.0-SNAPSHOT with the JSON-RPC node.
Proposed: unwrap it the same way (the receipt or null), with a note in the
upgrade guide.
h4. 3. The default operation transaction is not valid for the consumer
The {{operation}} option defaults to {{transaction}} ({{Web3jConfiguration}}
lines 30-31). The producer does nothing for it, and a consumer with no
{{operation}} fails at start with "Unsupported operation transaction"
({{Web3jConsumer}} line 153). Checked on 4.24.0-SNAPSHOT with the JSON-RPC node.
Proposed: fail with a clear message that the consumer needs one of the
observable operations (and that the producer needs an operation), or document
that {{operation}} is required.
h4. 4. Stopping a consumer reports an UndeliverableException when
eth_uninstallFilter fails
{{Web3jConsumer.doStop}} (main 2a465aa4814c, line 304) disposes the
subscription; web3j then calls {{eth_uninstallFilter}}, and when the node
answers with an error it goes to the RxJava global error handler as an
{{UndeliverableException}} with a stack trace on the shutdown thread. Checked
on 4.24.0-SNAPSHOT with the fake JSON-RPC node only.
Proposed: handle the failure of the filter removal on stop (log it at DEBUG) so
it does not reach the RxJava global error handler.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)