vertx-kafka-client icon indicating copy to clipboard operation
vertx-kafka-client copied to clipboard

Kafka Consumer subscribe method eats exceptions producing no output

Open lonerzzz opened this issue 7 years ago • 7 comments

I am using 3.4.2 of vertx and the kafka client for consuming events from a queue.

I have found that when some exceptions happen when attempting to subscribe to a topic via the following method in the KafkaReadStream class:

public KafkaReadStream<K, V> subscribe(Set<String> topics, Handler<AsyncResult<Void>> completionHandler)

the resulting exception gets caught by the catch (Throwable ex) block of the FutureTask run() method and stored with the setException(Throwable t) method and can ultimately be passed to the ThreadPoolExecutor implementation of the afterExecute method:

protected void afterExecute(Runnable r, Throwable t) { }

where nothing is done. Subsequently no result is returned and the callback is never called making debugging of the issue more difficult.

lonerzzz avatar Jan 10 '18 02:01 lonerzzz

can you give a try with Vert.x 3.5.0 ?

vietj avatar Jan 10 '18 08:01 vietj

Finally got back to this. The issue is bigger than just the implementation of this code and is an issue with how the java.util.concurrent code FutureTask is implemented and used. However, in this case, the cause is with the KafkaReadStream start method creating a single thread executor with the Executors.newSingleThreadExecutor() method. The resulting ThreadExecutor and FutureTask implementations catch exceptions in the FutureTask run() method and save them but do not pass them along to the ThreadExecutor. I have raised a vert.x wide issue on this because this will occur for many situations involving the ThreadExecutor and FutureTask.

The related common issue is: https://github.com/vert-x3/issues/issues/392

lonerzzz avatar Jul 22 '18 20:07 lonerzzz

I tried to reproduce the issue here: https://github.com/aesteve/vertx-kafka-subscribe-reproducer

aesteve avatar May 19 '20 11:05 aesteve

@vietj did you see this?

ppatierno avatar May 25 '20 16:05 ppatierno

yes we should do something

vietj avatar May 25 '20 20:05 vietj

Is there any progress done?

sknot-rh avatar Nov 11 '20 14:11 sknot-rh

Is this still valid in 4.x where the ThreadPoolExecutor was changed?

slinkydeveloper avatar Jan 22 '21 10:01 slinkydeveloper