davsclaus opened a new pull request, #30515:
URL: https://github.com/apache/camel/pull/30515

   ## What
   
   [CAMEL-27305](https://issues.apache.org/jira/browse/CAMEL-27305): the 
camel-kafka-share consumer logs an `Error` thrown out of `poll` at ERROR and 
terminates visibly. This is the same fix as #30496 (CAMEL-27298) in camel-kafka.
   
   ## Why
   
   The Kafka share client wraps only a `RuntimeException` of a deserializer in 
a `RecordDeserializationException`. I checked `ShareCompletedFetch.parseRecord` 
in the kafka-clients 4.4.0 bytecode: an `Error` comes out of `poll` as is. One 
example is the `ExceptionInInitializerError` of a protobuf class generated for 
a newer protobuf-java (CAMEL-27300). `KafkaShareFetchRecords` handled only 
exceptions, and the task is started with `executor.submit`, so the `Error` 
ended up in a `Future` that nobody reads:
   
   - nothing was logged at WARN or ERROR, not even the "Terminating" line;
   - the share consumer was closed by the `finally` of `run()`, so the health 
check was DOWN. But it said "recovery in progress" and showed no error, and the 
consumer never recovered.
   
   ## Changes
   
   - `KafkaShareFetchRecords.run()` catches `RuntimeException | Error`, logs it 
at ERROR, and sets a `KafkaConsumerFatalException` as the last error. It then 
terminates and rethrows. The health check now says "terminated ... restart 
route or application to recover", with the cause.
   - A `VirtualMachineError` is still rethrown untouched.
   - The share consumer is still closed in `finally`, so its records go to the 
other consumers of the share group.
   - The consumer terminates rather than following `pollOnError`: an `Error` 
such as a class that failed to initialise fails every poll the same way.
   - `kafka-share-component.adoc` (Health check) has a paragraph on this, and 
the catalog copy is synced.
   
   ## Tests
   
   - New `KafkaShareConsumerErrorTest.pollFailingWithAnErrorTerminatesVisibly`: 
a share consumer whose `poll` throws an `ExceptionInInitializerError`. It 
checks that:
     - the share consumer is closed;
     - the health check is DOWN with "terminated" and the cause;
     - the error is a `KafkaConsumerFatalException` that wraps the `Error`;
     - no new share consumer is created.
   - Without the fix, the test fails: the health message says "recovery in 
progress".
   - `RecordingShareConsumer.failNextPoll` can now also throw an `Error`.
   - camel-kafka-share: 1034 tests, all pass.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to