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

KNetSerDes does not work when types managed from Apache Kafka are used as key or value #221

Closed
masesdevelopers opened this issue Aug 31, 2023 · 1 comment · Fixed by #222
Assignees
Labels
bug Something isn't working KNet KNet related issue

Comments

@masesdevelopers
Copy link
Contributor

masesdevelopers commented Aug 31, 2023

Describe the bug
The class

public class KNetSerDes<T> : IKNetSerializer<T>, IKNetDeserializer<T>
does not work well using types managed from Apache Kafka.

To Reproduce
Steps to reproduce the behavior:

  1. Try to allocate KNetProducer using an int as key
  2. Try to produce something
  3. An exception is raised

Expected behavior
The record is produced to the topic

Screenshots
No screenshot

Additional context
The problem seems related to the SerSes allocated from KNetSerialization

@masesdevelopers masesdevelopers added bug Something isn't working KNet KNet related issue labels Aug 31, 2023
@masesdevelopers masesdevelopers self-assigned this Aug 31, 2023
@masesdevelopers
Copy link
Contributor Author

The problem is in the type used to invoke the serialization/deserialization like in the following line

static readonly Serializer<int> _IntSerializer = new IntegerSerializer();

When the previous line allocates the object it is converted with the following line
public static implicit operator Serializer<int>(IntegerSerializer t) => t.Cast<Serializer<int>>();
which casts to class instead to returns an interface, so at runtime the method invoked is the one below
public virtual byte[] Serialize(string arg0, object arg1)
and it returns the default value of the type without serializing anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working KNet KNet related issue
Projects
None yet
1 participant