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

SerDes creates too many listener instances #448

Closed
masesdevelopers opened this issue May 11, 2024 · 1 comment · Fixed by #449, #452, #429 or #453
Closed

SerDes creates too many listener instances #448

masesdevelopers opened this issue May 11, 2024 · 1 comment · Fixed by #449, #452, #429 or #453
Assignees
Labels
bug Something isn't working KNet KNet related issue .NET Pull requests that update .net code

Comments

@masesdevelopers
Copy link
Contributor

Describe the bug
Allocation of

public class SerDes<T, TJVMT> : ISerDes<T, TJVMT>
creates too many listener instances

To Reproduce
Steps to reproduce the behavior:

  1. Execute any test program which instantiate the following class
    public class SerDes<T, TJVMT> : ISerDes<T, TJVMT>
  2. On each instantiation the registered listeners in JCOBridge raise

Expected behavior
Since the following

Serde<TJVMT> _KafkaSerde;
Serializer<TJVMT> _KafkaSerializer;
Deserializer<TJVMT> _KafkaDeserializer;
are used to send to the JVM references to serializer interfaces, no listeners shall be activated because .NET shall not react on event.

Screenshots

Desktop (please complete the following information):

  • Version latest

Additional context
N/A

@masesdevelopers masesdevelopers added bug Something isn't working KNet KNet related issue .NET Pull requests that update .net code labels May 11, 2024
@masesdevelopers masesdevelopers self-assigned this May 11, 2024
@masesdevelopers
Copy link
Contributor Author

The problem is strictly related to listeners and comes from many things:

  • considering Serializer<TJVMT>, it inherits from MASES.JCOBridge.C2JBridge.JVMBridgeListener because the .NET side shall be informed if JVM requests something
  • this invocation in
    _KafkaSerializer = kafkaSerde.Serializer();
    requests an instance of JVM Serializer interface, not the listener JVM class, and cast it to .NET Serializer<TJVMT>
  • the class Serializer<TJVMT>, by definition, has AutoInit flag set to true, so it initialize an MASES.JCOBridge.C2JBridge.JVMBridgeListener

To avoid the problem the code shall be updated to:

  • create a new class named, e.g. SerializerDirect<TJVMT> which:
    • extends Serializer<TJVMT>
    • overrides AutoInit and set it to false
    • overrides the BridgeClassName and set its value to the JVM interface name e.g. org.apache.kafka.common.serialization.Serializer
  • override
    public virtual Org.Apache.Kafka.Common.Serialization.Serializer<T> Serializer()
    in a new class named SerDesDirect<TJVMT> and within it allocate the SerializerDirect<TJVMT> class

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 .NET Pull requests that update .net code
Projects
None yet
1 participant