Skip to content

fix: support java.util.Date in RecordConverter.convertLong - #17690

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/convertLong-date-15344
Open

fix: support java.util.Date in RecordConverter.convertLong#17690
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/convertLong-date-15344

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #15344

Problem

When using Confluent Avro converter, timestamp-millis fields are deserialized as java.util.Date objects. RecordConverter.convertLong() only handles Number and String, causing IllegalArgumentException: Cannot convert to long: java.util.Date.

Fix

Add Date handling to convertLong() via Date.getTime() to extract epoch millis, matching the existing pattern used by convertDateValue, convertTimeValue, convertOffsetDateTime, and convertLocalDateTime which all handle Date.

Testing

  • Existing test suite passes locally
  • New Date values are properly converted to long epoch millis

When Confluent Avro converter deserializes timestamp-millis as
java.util.Date, RecordConverter.convertLong() throws because it only
handles Number and String. Add Date handling via getTime() to extract
epoch millis.

Fixes apache#15344

@ebyhr ebyhr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update TestRecordConverter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kafka Connect: RecordConverter.convertLong() fails with java.util.Date from Confluent Avro converter

2 participants