This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new c1b30d47b746 CAMEL-26516: camel-web3j - document the 
UndeliverableException when web3j fails to uninstall a filter (#29113)
c1b30d47b746 is described below

commit c1b30d47b746e8da659a4773459fda5036af2e2f
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 4 16:28:06 2026 +0100

    CAMEL-26516: camel-web3j - document the UndeliverableException when web3j 
fails to uninstall a filter (#29113)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/catalog/docs/web3j-component.adoc | 40 ++++++++++++++++++++++
 .../camel-web3j/src/main/docs/web3j-component.adoc | 40 ++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/web3j-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/web3j-component.adoc
index fd1ebba1d52d..b2494b2b96bd 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/web3j-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/web3j-component.adoc
@@ -171,3 +171,43 @@ YAML::
               atBlock: 10
 ----
 ====
+
+== UndeliverableException when a filter is removed
+
+The consumer operations `ETH_LOG_OBSERVABLE`, `ETH_BLOCK_HASH_OBSERVABLE`, 
`ETH_PENDING_TRANSACTION_HASH_OBSERVABLE`,
+`BLOCK_OBSERVABLE`, `TRANSACTION_OBSERVABLE` and 
`PENDING_TRANSACTION_OBSERVABLE` install a filter on the node and poll it.
+web3j removes the filter with `eth_uninstallFilter` when the consumer stops. 
For `BLOCK_OBSERVABLE`,
+`TRANSACTION_OBSERVABLE` and `PENDING_TRANSACTION_OBSERVABLE`, web3j also 
removes it when fetching a block or a
+transaction fails, before the consumer subscribes again.
+
+If `eth_uninstallFilter` fails, for example because the node is down or has 
already dropped the filter, RxJava reports an
+`io.reactivex.exceptions.UndeliverableException` caused by web3j's 
`org.web3j.protocol.core.filters.FilterException`.
+By default RxJava prints the stack trace and passes it to the uncaught 
exception handler of the thread.
+This is only noise: the consumer keeps working. The cause is in web3j, see
+https://github.com/LFDT-web3j/web3j/issues/1937[web3j issue 1937].
+
+To log these errors at a lower level, an application can set a JVM-wide RxJava 
2 error handler once at startup,
+before the routes start. The handler below logs the web3j filter errors at 
DEBUG and handles all other errors as RxJava
+does by default:
+
+[source,java]
+----
+import io.reactivex.exceptions.UndeliverableException;
+import io.reactivex.plugins.RxJavaPlugins;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.web3j.protocol.core.filters.FilterException;
+
+Logger LOG = LoggerFactory.getLogger("web3j-filters");
+
+RxJavaPlugins.setErrorHandler(e -> {
+    if (e instanceof UndeliverableException && e.getCause() instanceof 
FilterException) {
+        LOG.debug("web3j could not uninstall a filter: {}", 
e.getCause().getMessage());
+        return;
+    }
+    // what RxJava does when no error handler is set
+    e.printStackTrace();
+    Thread thread = Thread.currentThread();
+    thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
+});
+----
diff --git a/components/camel-web3j/src/main/docs/web3j-component.adoc 
b/components/camel-web3j/src/main/docs/web3j-component.adoc
index fd1ebba1d52d..b2494b2b96bd 100644
--- a/components/camel-web3j/src/main/docs/web3j-component.adoc
+++ b/components/camel-web3j/src/main/docs/web3j-component.adoc
@@ -171,3 +171,43 @@ YAML::
               atBlock: 10
 ----
 ====
+
+== UndeliverableException when a filter is removed
+
+The consumer operations `ETH_LOG_OBSERVABLE`, `ETH_BLOCK_HASH_OBSERVABLE`, 
`ETH_PENDING_TRANSACTION_HASH_OBSERVABLE`,
+`BLOCK_OBSERVABLE`, `TRANSACTION_OBSERVABLE` and 
`PENDING_TRANSACTION_OBSERVABLE` install a filter on the node and poll it.
+web3j removes the filter with `eth_uninstallFilter` when the consumer stops. 
For `BLOCK_OBSERVABLE`,
+`TRANSACTION_OBSERVABLE` and `PENDING_TRANSACTION_OBSERVABLE`, web3j also 
removes it when fetching a block or a
+transaction fails, before the consumer subscribes again.
+
+If `eth_uninstallFilter` fails, for example because the node is down or has 
already dropped the filter, RxJava reports an
+`io.reactivex.exceptions.UndeliverableException` caused by web3j's 
`org.web3j.protocol.core.filters.FilterException`.
+By default RxJava prints the stack trace and passes it to the uncaught 
exception handler of the thread.
+This is only noise: the consumer keeps working. The cause is in web3j, see
+https://github.com/LFDT-web3j/web3j/issues/1937[web3j issue 1937].
+
+To log these errors at a lower level, an application can set a JVM-wide RxJava 
2 error handler once at startup,
+before the routes start. The handler below logs the web3j filter errors at 
DEBUG and handles all other errors as RxJava
+does by default:
+
+[source,java]
+----
+import io.reactivex.exceptions.UndeliverableException;
+import io.reactivex.plugins.RxJavaPlugins;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.web3j.protocol.core.filters.FilterException;
+
+Logger LOG = LoggerFactory.getLogger("web3j-filters");
+
+RxJavaPlugins.setErrorHandler(e -> {
+    if (e instanceof UndeliverableException && e.getCause() instanceof 
FilterException) {
+        LOG.debug("web3j could not uninstall a filter: {}", 
e.getCause().getMessage());
+        return;
+    }
+    // what RxJava does when no error handler is set
+    e.printStackTrace();
+    Thread thread = Thread.currentThread();
+    thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
+});
+----

Reply via email to