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

   ## Summary
   
   Three bugs fixed in `camel-kafka` dev console and idempotent repository:
   
   1. **KafkaDevConsole** — wrong epoch display: "Commit Offset Since" 
subtracted the Kafka leader epoch (a small integer like 0, 1, 2…) from 
`System.currentTimeMillis()`, producing a ~56-year duration string. Fixed to 
display the leader epoch number directly as "Commit Leader Epoch: N".
   
   2. **DefaultMetricsCollector** — NPE + latch deadlock: 
`Consumer.committed()` returns `null` values for partitions that have never 
committed an offset. The code called `e.getValue().offset()` unconditionally, 
throwing NPE. When the exception was caught, `latch.countDown()` was never 
called, leaving the dev console request thread blocked until timeout. Fixed: 
skip null `OffsetAndMetadata` entries and always release the latch in the catch 
block.
   
   3. **KafkaIdempotentRepository** — missing `@Metadata`: `consumerConfig` and 
`producerConfig` fields lacked `@Metadata` annotations, making them invisible 
to the dev console and bean introspection tooling. Added `@Metadata` with 
description, `label = "advanced"`, and `javaType`. Updated generated JSON 
descriptors accordingly.
   
   ## Root Cause
   
   - Epoch display: `KafkaTopicPosition.epoch` stores the Kafka leader epoch, 
not a Unix timestamp — the original author confused the two.
   - NPE: the Kafka `Consumer.committed(Set<TopicPartition>)` javadoc states it 
may return null values for partitions with no committed offset; this case was 
not handled.
   - Latch: the try/catch swallowed the exception but forgot to release the 
caller's wait.
   - `@Metadata`: two fields were added later without the annotation.
   
   ## Fix
   
   - Replace `System.currentTimeMillis() - r.epoch()` / 
`TimeUtils.printDuration` with a direct display of the epoch integer.
   - Add a null-check on `e.getValue()` before accessing it; add 
`latch.countDown()` in the catch block.
   - Add `@Metadata(description = "...", label = "advanced", javaType = 
"java.util.Properties")` to both fields; update the two generated JSON files.
   
   ## Tests
   
   These bugs are in dev console and introspection code paths that require a 
live Kafka broker to test via integration tests. The fixes are straightforward 
defensive null-checks and annotation additions; correctness is verified by code 
review.
   
   Fixes CAMEL-27990
   
   ---
   _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
   


-- 
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