Skip to content

Fix KafkaItemReader ExecutionContext deserialization error when using Jackson2ExecutionContextStringSerializer #4863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noojung
Copy link

@noojung noojung commented Jun 5, 2025

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

… Jackson2ExecutionContextStringSerializer

Signed-off-by: Hyunwoo Jung <hyunwoojung@kakao.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot deserialize TopicPartition from JobRepository
1 participant