spring-batch
spring-batch copied to clipboard
Fix KafkaItemReader ExecutionContext deserialization error when using Jackson2ExecutionContextStringSerializer
When use Jackson2ExecutionContextStringSerializer, KafkaItemReader always encountered an ClassCastException.
Because KafkaItemReader stores a Map<TopicPartition, Long> in the ExecutionContext, Jackson2ExecutionContextStringSerializer forces all map keys to String.
So I change it to store only the partition number (as String) instead of TopicPartition directly.
This change:
- Modifies update() to save only the partition number (as a String) into the ExecutionContext
- Updates open() to read those String offsets and reconstruct each TopicPartition
As a result, KafkaItemReader can now successfully deserialize ExecutionContext without throwing an exception.
Resolves: #3797