Skip to content
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

Fast generic serializer enums fixed #4

Closed
wants to merge 8 commits into from

Conversation

krisso-rtb
Copy link

@krisso-rtb krisso-rtb commented Sep 5, 2023

It aims to fix below exception

class com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum cannot be cast to class org.apache.avro.generic.GenericData$EnumSymbol (com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum and org.apache.avro.generic.GenericData$EnumSymbol are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum cannot be cast to class org.apache.avro.generic.GenericData$EnumSymbol (com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum and org.apache.avro.generic.GenericData$EnumSymbol are in unnamed module of loader 'app')
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serializeFastSerdeEnums0(FastSerdeEnums_GenericSerializer_957378572.java:26)
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serialize(FastSerdeEnums_GenericSerializer_957378572.java:19)
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serialize(FastSerdeEnums_GenericSerializer_957378572.java:11)
	at com.linkedin.avro.fastserde.FastGenericSerializerGeneratorTest.dataAsBinaryDecoder(FastGenericSerializerGeneratorTest.java:615)

There are some extra commits so that we can see the actual changes of generated classes (and normally these classes are in .gitignore).

For now marked as ignored due to:

class com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum cannot be cast to class org.apache.avro.generic.GenericData$EnumSymbol (com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum and org.apache.avro.generic.GenericData$EnumSymbol are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum cannot be cast to class org.apache.avro.generic.GenericData$EnumSymbol (com.linkedin.avro.fastserde.generated.avro.JustSimpleEnum and org.apache.avro.generic.GenericData$EnumSymbol are in unnamed module of loader 'app')
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serializeFastSerdeEnums0(FastSerdeEnums_GenericSerializer_957378572.java:26)
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serialize(FastSerdeEnums_GenericSerializer_957378572.java:19)
	at com.linkedin.avro.fastserde.generated.serialization.AVRO_1_10.FastSerdeEnums_GenericSerializer_957378572.serialize(FastSerdeEnums_GenericSerializer_957378572.java:11)
	at com.linkedin.avro.fastserde.FastGenericSerializerGeneratorTest.dataAsBinaryDecoder(FastGenericSerializerGeneratorTest.java:615)
	at com.linkedin.avro.fastserde.FastGenericSerializerGeneratorTest.dataAsBinaryDecoder(FastGenericSerializerGeneratorTest.java:604)
	at com.linkedin.avro.fastserde.FastGenericSerializerGeneratorTest.shouldWriteSpecificRecordWithEnums(FastGenericSerializerGeneratorTest.java:192)
Copy link
Author

@krisso-rtb krisso-rtb left a comment

Choose a reason for hiding this comment

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

Root cause: when FastGenericSerializer serializes specific record then SchemaAssistant.classFromSchema()
returns

codeModel.ref(GenericData.EnumSymbol.class)

which is incorrect - specific record has its own Java-enum which inherits from GenericEnumSymbol, not org.apache.avro.generic.GenericData.EnumSymbol

@flowenol
Copy link

flowenol commented Sep 6, 2023

You could concisely clarify here what is the root cause of this problem and how it is resolved in the committed changes.

specific record using fast-generic-serializer.
@krisso-rtb
Copy link
Author

PR to source repository (linkedin) was created:

@krisso-rtb krisso-rtb closed this Sep 12, 2023
@krisso-rtb krisso-rtb deleted the fast-generic-serializer-enums-fixed branch September 13, 2023 16:15
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.

2 participants