Skip to content

Modify RmdUtils:getLastUpdateTimestamp to fix class cast exception#2283

Closed
suketkar wants to merge 2 commits intolinkedin:mainfrom
suketkar:sketkar/fix
Closed

Modify RmdUtils:getLastUpdateTimestamp to fix class cast exception#2283
suketkar wants to merge 2 commits intolinkedin:mainfrom
suketkar:sketkar/fix

Conversation

@suketkar
Copy link
Contributor

@suketkar suketkar commented Nov 13, 2025

Problem Statement

Caused by: java.lang.ClassCastException: class org.apache.avro.generic.GenericData$Array cannot be cast to class [J (org.apache.avro.generic.GenericData$Array is in unnamed module of loader 'app'; [J is in module java.base of loader 'bootstrap')

GenericDataArray treats the collection as list opposed to long[] array. Fixing the same.

Solution

Treat DELETED_ELEM_TS_FIELD_NAME and ACTIVE_ELEM_TS_FIELD_NAME as List/Collection instead of long array

How was this PR tested?

Unit tests

Copy link
Contributor

@mynameborat mynameborat left a comment

Choose a reason for hiding this comment

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

Can you make sure there is enough coverage in unit test? Looks like some of the code coverage checks are failing.

Comment on lines +175 to +176
@Test
public void testGetLastUpdateTimestampWithCollectionFields() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is not an existing test, can you add one for the top level field that contributes to maximum?

Comment on lines +161 to +174
// Handle DELETED_ELEM_TS_FIELD_NAME as a List/Collection
Object deletedTimestamps = fieldRecord.get(DELETED_ELEM_TS_FIELD_NAME);
if (deletedTimestamps instanceof List) {
for (Object ts: (List<?>) deletedTimestamps) {
lastUpdatedTimestamp = Math.max(lastUpdatedTimestamp, ((Number) ts).longValue());
}
}
for (long timestamp: (long[]) ((GenericRecord) ((GenericRecord) timestampRecord).get(field.name()))
.get(ACTIVE_ELEM_TS_FIELD_NAME)) {
lastUpdatedTimestamp = Math.max(lastUpdatedTimestamp, timestamp);

// Handle ACTIVE_ELEM_TS_FIELD_NAME as a List/Collection
Object activeTimestamps = fieldRecord.get(ACTIVE_ELEM_TS_FIELD_NAME);
if (activeTimestamps instanceof List) {
for (Object ts: (List<?>) activeTimestamps) {
lastUpdatedTimestamp = Math.max(lastUpdatedTimestamp, ((Number) ts).longValue());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract maximum inference to a method? Looks boiler plate.


// Handle DELETED_ELEM_TS_FIELD_NAME as a List/Collection
Object deletedTimestamps = fieldRecord.get(DELETED_ELEM_TS_FIELD_NAME);
if (deletedTimestamps instanceof List) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does instanceof List check covers all types of collection in avro?

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Hi there. This pull request has been inactive for 30 days. To keep our review queue healthy, we plan to close it in 7 days unless there is new activity. If you are still working on this, please push a commit, leave a comment, or convert it to draft to signal intent. Thank you for your time and contributions.

@github-actions github-actions bot added the stale label Jan 8, 2026
@github-actions
Copy link

Closing this pull request due to 37 days of inactivity. This is not a judgment on the value of the work. If you would like to continue, please reopen or open a new PR and we will be happy to take another look. Thank you again for contributing.

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.

2 participants